getsockname(2)
NAME
getsockname − get socket name
SYNTAX
int getsockname(s, name, namelen)
int s, *namelen;
struct sockaddr *name;
DESCRIPTION
The getsockname system call returns the current name for socket s. The specified namelen should be initialized to indicate the amount of space pointed to by name. On return, it contains the actual size of the name returned (in bytes).
RESTRICTIONS
Names bound to sockets in the UNIX domain are inaccessible. The getsockname call returns a zero length name.
RETURN VALUE
If unsuccessful, returns a −1, and the global variable errno indicates the error code.
DIAGNOSTICS
The getsockname call will fail if:
[EBADF] The specified s is not a valid descriptor.
[ENOTSOCK] The specified s is a file, not a socket.
[ENOBUFS] Insufficient resources were available in the system to perform the operation.
[EFAULT] The specified name points to memory that is not in a valid part of the process address space.