I have a tcp connected socket handle, created through an accept. Only the handle, not other structs. How can I retrieve its REMOTE port from the handle? I mean, the tcp source port of the connection Remote Client ---> Me
-
Yes, the other structs. 2nd argument, sockaddr_in.sin_port.Hans Passant– Hans Passant2010-11-02 21:20:57 +00:00Commented Nov 2, 2010 at 21:20
-
possible duplicate of Determining the TCP port number to which client got bound.Jens Gustedt– Jens Gustedt2010-11-02 22:12:11 +00:00Commented Nov 2, 2010 at 22:12
Add a comment
|
1 Answer
The getpeername function gets information about the remote side, including the port number; getsockname does the same for the local side of the connection.