When I establish a tcp connection to a server using the TcpClient class, is there any way to find out the source port of this connection? I am trying to implement the exec protocol and stderr port seems to always be source port + 1.
A:
Use ((IPEndPoint) tcpClient.Client.LocalEndPoint).Port
after establishing the connection.
Gonzalo
2009-11-19 03:30:44
Port does not seem to be a property of LocalEndPoint.
Matthew
2009-11-19 03:35:18
Ah, forgot to cast to IPEndPoint.
Gonzalo
2009-11-19 03:36:06
So cast LocalEndPoint as a IPEndPoint and should work ok? I will try :)
Matthew
2009-11-19 03:37:27
Hooray. Thankyou very much! The cast worked fine!A++++++++++++++
Matthew
2009-11-19 03:42:52
A:
Solved :)
Client sends TCP port number (decimal ascii, null-terminated) of stderr port. If the first byte is a NULL, then server won't make any stderr connection.
Matthew
2009-11-19 03:33:49