get the name of the peer connected to a socket
#include <sys/socket.h> int getpeername( int s, struct sockaddr *name, int *namelen );
The getpeername() function returns the name of the peer connected to socket s. You should initialize the namelen parameter to indicate the amount of space pointed to by name. On return, namelen contains the actual size of the name (in bytes). The name is truncated if the buffer provided is too small.
The address of the remote socket, or -1 if an error occurs (errno is set).
If an error occurred, errno could contain one of the following:
POSIX 1003.1g (draft)
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |