#include <sys/types.h>
#include <sys/socket.h>
int getpeername(int socket_descriptor,
struct sockaddr *destination_address,
int *address_length)
|
The getpeername() function is used to retrieve the destination address to which the socket is connected.
Parameters
struct sockaddr {
u_short sa_family;
char sa_data[14];
};
The sa_family field identifies the address family to which the address belongs, and sa_data is the address whose format is dependent on the address family.
Return Value
getpeername() returns an integer. Possible values are:
Error Conditions
When getpeername() fails, errno can be set to one of the following:
The system detected an address which was not valid while attempting to access the destination_address or address_length parameters.
The address_length parameter specifies a negative value.
Error Messages
Usage Notes
Related Information
| Top | Sockets APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |