|
Description
The getsockname() function returns the current name for socket s.
name points to a memory area. After successful execution of getsockname(), *name contains the name (address) of socket s. The actual format of the sockaddr structure depends on the address family involved and is described in the section "Socket addressing".
The size_t variable to which the namelen parameter points initially indicates the size of the memory area referenced by name. When the function returns, *name contains the current size of the returned name in bytes.
Return value
0:
If successful.
-1:
If errors occur. errno is set to indicate the error.
Errors
EBADF
The s parameter is not a valid descriptor.
EFAULT
The name parameter points to an area outside the process address range.
ENOTSOCK
Descriptor s references a file and not a socket.