Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (f - i) getpeername(2)
NAME
getpeername - Gets the name of the peer socket
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
SYNOPSIS
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>
int getpeername(
int socket,
struct sockaddr *address,
socklen_t *address_len);
PARAMETERS
socket Specifies the open file descriptor of the socket.
address Points to a sockaddr structure, where the address of the peer socket is returned.
If the length of the address is greater than the length of the supplied sockaddr
structure, the address is truncated when stored.
If the protocol permits connection by unbound clients, and if the peer socket is
not bound to an address, then the value stored is unspecified.
The length and format of the address depend on the address family of the socket.
For AF_INET sockets, a pointer to the address structure sockaddr_in can be
cast as a struct sockaddr.ForAF_INET6 sockets, a pointer to the address
structure sockaddr_in6 can be cast as a struct sockaddr.ForAF_UNIX sock-
ets, a pointer to the address structure sockaddr_un must be cast as a struct
sockaddr.
address_len Points to a socklen_t data item, which, on input, specifies the length of the
sockaddr structure pointed to by the address parameter, and, on output, specifies
the length of the address returned.
DESCRIPTION
The getpeername() function retrieves the peer address of the specified socket, stores this
address in the sockaddr structure pointed to by the address parameter, and stores the length of
this address in the object pointed to by the address_len parameter.
The behavior of this function differs depending on the type of socket and whether the socket is an
AF_UNIX Release 1 socket or an AF_UNIX Release 2 socket in compatibility mode, or the
socket is an AF_UNIX Release 2 socket in portability mode.
527186-023 Hewlett-Packard Company 3−75