Сначала мы установили первый сокет:
Socket socket1;
IPEndPoint localEP = new IPEndPoint (IPAddress.Any, 20000);
Socket1 = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket1.Bind (localEP);
Затем второй сокет:
Socket socket2
IPEndPoint localEP = new IPEndPoint (IPAddress.Any, 20000);
Socket2 = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket2.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
/ / Please note this one. True ReuseAddress options will be set to allow the socket to bind already in use in the address.
Socket2.Bind (localEP);
Это будет связано Socket1 и Socket2 в одном и том же порту на.