|
Description
The getpeername() returns the name of the communications partner connected to socket s.
name points to a memory area. After getpeername() has been executed successfully, *name contains the address of the communications partner.
The size_t variable, to which the namelen parameter points, initially indicates the size of the memory area referenced by name. After the function returns, *namelen 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.
ENOTCONN
The socket has no connection.
ENOTSOCK
Descriptor s references a file and not a socket.