/// <summary> /// Initialize the UDP client, and send connection request to the server /// </summary> /// <param name="serverIP"></param> /// <returns></returns> private UdpClient InitializeUDPClient(string serverIP) { LogFile.WriteLineToLog(LogFile.FileNames.client, "UDP Connecting"); //create udp listener to get port UdpClient udpClient = new UdpClient(); udpClient.Connect(serverIP, NetworkServer.UDP_PORT); LogFile.WriteLinesToLog(LogFile.FileNames.client, new string[] { "UDP Connected", "Local End Point: " + udpClient.Client.LocalEndPoint.ToString(), "Remote End Point: " + udpClient.Client.RemoteEndPoint.ToString() } ); UdpConnectionIn udpIn = new UdpConnectionIn(udpClient); //create UDPOut connection UdpConnectionOut udpOut = new UdpConnectionOut(udpClient); //Encapsulate udp connections udp = new UdpConnection(udpIn, udpOut); udp.Send(NetworkControlCode.runOnServer, NetSerialize.Serialize(new NetworkServer.UdpConnectServerEvent())); LogFile.WriteLineToLog(LogFile.FileNames.client, "UDP Connection Request Sent"); return(udpClient); }
public UdpConnection(UdpConnectionIn inConnection, UdpConnectionOut outConnection) { this.inConnection = inConnection; this.outConnection = outConnection; }