2009-08-22 8 views

Antwort

0

Wir zunächst den ersten Sockel:

 Socket socket1; 
    IPEndPoint localEP = new IPEndPoint (IPAddress.Any, 20000); 
    Socket1 = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 
    Socket1.Bind (localEP); 

Dann wird ein zweiter Sockel:

 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); 

Diese Socket1 und socket2 in den gleichen Port auf das gebündelte wird .

2

Rufen Sie einfach die Stop-Methode auf dem TcpListener auf.