getpeername(2)
Requires Optional LAN/X.25 Software
NAME
getpeername − get address of connected peer
SYNOPSIS
#include <sys/socket.h>
AF_CCITT only:
#include <x25/x25addrstr.h>
int getpeername(int s, void ∗addr, int ∗addrlen);
DESCRIPTION
s is a socket descriptor. getpeername returns the address of the peer socket connected to the socket indicated by s. addr points to a socket address structure in which this address is returned. addrlen points to an object of type int, which should be initialized to indicate the size of the address structure. On return, it contains the actual size of the address returned (in bytes). If addr does not point to enough space to contain the whole address of the peer, only the first addrlen bytes of the address are returned.
AF_CCITT only:
The addr struct contains the X.25 addressing information of the remote peer socket connected to socket s. However, the x25ifname[] field of the addr struct contains the name of the local X.25 interface through which the call arrived.
RETURN VALUE
If the call is successful, 0 is returned. If the call fails, −1 is returned and an error code is stored in errno.
DIAGNOSTICS
getpeername fails if:
[EBADF] The argument s is not a valid file descriptor.
[ENOTSOCK] The argument s is a file, not a socket.
[ENOTCONN] The socket is not connected.
[ENOBUFS] Insufficient resources were available in the system to perform the operation.
[EFAULT] The addr or addrlen parameters are not valid pointers.
[EINVAL] The socket has been shut down.
[EOPNOTSUPP] Operation not supported for AF_UNIX sockets.
AUTHOR
getpeername was developed by the University of California, Berkeley.
SEE ALSO
bind(2), socket(2), getsockname(2), inet(7F), af_ccitt(7F).
Hewlett-Packard Company — HP-UX Release 8.05: June 1991