1.1.27.19 getpeername
C
int getpeername(int fd, struct sockaddr *addr, socklen_t *addrlen)Description
Returns the address of the peer connected to the socket fd.
Parameters
| Parameters | Description |
|---|---|
| fd | Socket file descriptor. |
| addr | Pointer to address structure. |
| addrlen | Length of address structure. |
Returns
On success, zero is returned.
On error, -1 is returned, and errno is set to indicate the error.
Remarks
| errno | Description |
|---|---|
| EFAULT | System fault. |
| EINVAL | addrlen is invalid (e.g., is negative). |
| ENOTSOCK | The file descriptor fd does not refer to a socket. |
| ENOTCONN | The socket is not connected, and no target has been given. |
