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

ParametersDescription
fdSocket file descriptor.
addrPointer to address structure.
addrlenLength of address structure.

Returns

On success, zero is returned.

On error, -1 is returned, and errno is set to indicate the error.

Remarks

errnoDescription
EFAULTSystem fault.
EINVALaddrlen is invalid (e.g., is negative).
ENOTSOCKThe file descriptor fd does not refer to a socket.
ENOTCONNThe socket is not connected, and no target has been given.