2010-05-19 21 views

Odpowiedz

15

constructor overload that takes an IPEndPoint pozwala powiązać wewnętrzne gniazda TcpClient do określonego portu:

IPAddress ipAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0]; 
IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, clientPort); 
TcpClient clientSocket = new TcpClient(ipLocalEndPoint); 
clientSocket.Connect(remoteHost, remotePort); 
+1

W testach niedawno, musiałem użyć nieco inną linię, aby połączyć: clientSocket.Client .Connect (remoteHost, remotePort); . Użycie clientSocket.Connect zmieniłoby mnie na clientPort. –

Powiązane problemy