GETPEERNAME [ Berkeley Sockets/iX Reference Manual ] MPE/iX 5.0 Documentation
Berkeley Sockets/iX Reference Manual
GETPEERNAME
C Interface
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
getpeername(s, addr, addrlen)
int s;
struct sockaddr_in *addr;
int *addrlen;
Description
S is a socket descriptor. The getpeername system call returns the
address of the peer socket connected to the socket indicated by s. The
addr parameter points to a socket address structure in which this address
is returned. The addrlen parameter points to an object of the type int,
which should be initialized to indicate the size of the address
structure. On return, the addrlen parameter 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.
This call is supported for AF_INET only.
Return Value
If the call is successful, a 0 is returned. If the call fails, a -1 is
returned, and an error code is stored in errno.
Errors
The following errors are returned by getpeername:
[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] The operation is not supported for AF_UNIX sockets.
Author
UCB (University of California at Berkeley)
See Also
bind, socket, getsockname
MPE/iX 5.0 Documentation