'\"macro stdmacro
.if n .pH g3n.getpeername @(#)getpeername	40.7 of 1/29/90
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} getpeername 3N "" "\&"
.if \nX=1 .ds x} getpeername 3N ""
.if \nX=2 .ds x} getpeername 3N "" "\&"
.if \nX=3 .ds x} getpeername "" "" "\&"
.TH \*(x}
.SH NAME
\f4getpeername\fP \- get name of connected peer
.SH SYNOPSIS
.nf
.LP
.ft 4
int getpeername(s, name, namelen)
int s;
struct sockaddr \(**name;
int \(**namelen;
.fi
.SH DESCRIPTION
.LP
\f4getpeername\fP(\|)
returns the name of the peer connected to socket
.IR s .
The
\f4int\fP
pointed to by the
.I namelen
parameter should be initialized to indicate
the amount of space pointed to by
.IR name .
On return it contains the actual size of the name
returned\fP(in bytes).
The name is truncated if the buffer provided is too small.
.SH RETURN VALUE
.LP
\f40\fP is returned if the call succeeds, \f4-1\fP if it fails.
.SH ERRORS
.LP
The call succeeds unless:
.TP 20
\f4EBADF\f1
The argument
.I s
is not a valid descriptor.
.TP
\f4ENOTSOCK\f1
The argument
.I s
is a file, not a socket.
.TP
\f4ENOTCONN\f1
The socket is not connected.
.TP
\f4ENOMEM\f1
There was insufficient user memory for the operation
to complete.
.TP
\f4ENOSR\f1
There were insufficient
.SM STREAMS
resources available for the operation to complete.
.SH "SEE ALSO"
\f4accept\fP(3N),
\f4bind\fP(3N),
\f4getsockname\fP(3N),
\f4socket\fP(3N)
