Find local IP address and local port number using getsockname

The getsockname function can be used to find the local port used by a given socket. It is valid to use this function only if the socket is already using a local port number. i.e A server socket which invoked bind system call with zero as port number. A client socket which has established connection to a server. Read the “Find local IP address and local port number using getsockname” article for more details.

http://www.techpulp.com/articles/networking/snip-find-local-addr-using-getsockname.php

Leave a Comment