COHERENT manpages

This page displays the COHERENT manpage for getpeername() [Get name of connected peer].

List of available manpages
Index


getpeername() -- Sockets Function (libsocket)

Get name of connected peer
int getpeername(socket, name, namelen)
int socket, *namelen; struct sockaddr *name;

getpeername() returns the name of  the ``peer socket'' that is connected to
socket.

name points  to the space into  which getpeername() writes the  name of the
peer.  namelen points to an integer that gives the amount of space to which
name points.   getpeername() re-initializes it to the  length, in bytes, of
the peer name that it has written at name.

If  all goes  well, getpeername()  returns  zero.  If  an error  occurs, it
returns -1 and sets errno to an appropriate value.  The following lists the
errors that can occur, by the value to which getpeername() sets errno:

EBADF
     socket is not a valid descriptor.

ENOTSOCK
     socket describes a file, not a socket.

ENOTCONN
     socket is not connected.

ENOBUFS
     The system lack resources to perform the operation.

EFAULT
     name contains an illegal address.

See Also

accept(),
bind(),
getsockname(),
libsocket,
socket()