getpeername
Purpose
Gets the name of the connected peer.
Library
Sockets Library (libsock.a)
Syntax
int getpeername (s, name, namelen)
int s;
struct sockaddr *name;
int *namelen;
Description
The getpeername subroutine returns the name of the peer,
or connected socket, that is connected to the socket
specified by the s parameter. You should initialize the
namelen to indicate the amount of space pointed to by
name. On return, it contains the actual size of the name
returned (in bytes).
Return Value
Upon successful completion, a value of 0 is returned. If
the getpeername routine fails, a value of -1 is returned,
and errno is set to indicate the error.
Diagnostics
The subroutine fails if one or more of the following are
true:
EBADF The s parameter is not valid.
ENOTSOCK The s parameter refers to a file, not a
socket.
ENOTCONN The socket is not connected.
ENOBUFS Insufficient resources were available
in the system to complete the call.
EFAULT The addr parameter is not in a writable
part of the user address space.
Related Information
In this book: "bind," "socket," and "getsockname."