Returns the current name of a socket.
#include <sys/socket.h>
int getsockname (
int s,
struct sockaddr *addr,
size_t *len);
(IN) Specifies the socket file handle connected to the peer for which the name is to be returned.
(OUT) Points to the location of the name for the peer connected to the socket. For IPv4, addr points to a sockaddr structure; for IPv6, to a sockaddr_in6 structure. The first two bytes in the structures identify the protocol family, and hence the structure.
(OUT) Points to the size of the name pointed to by addr.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following: