xref: /csrg-svn/lib/libc/sys/getpeername.2 (revision 61181)
1*61181Sbostic.\" Copyright (c) 1983, 1991, 1993
2*61181Sbostic.\"	The Regents of the University of California.  All rights reserved.
320233Smckusick.\"
443568Strent.\" %sccs.include.redist.man%
520233Smckusick.\"
6*61181Sbostic.\"     @(#)getpeername.2	8.1 (Berkeley) 06/04/93
736759Sbostic.\"
847208Scael.Dd
947208Scael.Dt GETPEERNAME 2
1047208Scael.Os BSD 4.2
1147208Scael.Sh NAME
1247208Scael.Nm getpeername
1347208Scael.Nd get name of connected peer
1447208Scael.Sh SYNOPSIS
1547208Scael.Ft int
1647208Scael.Fn getpeername "int s" "struct sockaddr *name" "int *namelen"
1747208Scael.Sh DESCRIPTION
1847208Scael.Fn Getpeername
1920233Smckusickreturns the name of the peer connected to
2020233Smckusicksocket
2147208Scael.Fa s .
2220233SmckusickThe
2347208Scael.Fa namelen
2420233Smckusickparameter should be initialized to indicate
2520233Smckusickthe amount of space pointed to by
2647208Scael.Fa name .
2720233SmckusickOn return it contains the actual size of the name
2820233Smckusickreturned (in bytes).
2928079SkarelsThe name is truncated if the buffer provided is too small.
3047208Scael.Sh DIAGNOSTICS
3147208ScaelA 0 is returned if the call succeeds, -1 if it fails.
3247208Scael.Sh ERRORS
3320233SmckusickThe call succeeds unless:
3447208Scael.Bl -tag -width ENOTSOCKAA
3547208Scael.It Bq Er EBADF
3647208ScaelThe argument
3747208Scael.Fa s
3847208Scaelis not a valid descriptor.
3947208Scael.It Bq Er ENOTSOCK
4047208ScaelThe argument
4147208Scael.Fa s
4247208Scaelis a file, not a socket.
4347208Scael.It Bq Er ENOTCONN
4420233SmckusickThe socket is not connected.
4547208Scael.It Bq Er ENOBUFS
4620233SmckusickInsufficient resources were available in the system
4720233Smckusickto perform the operation.
4847208Scael.It Bq Er EFAULT
4920233SmckusickThe
5047208Scael.Fa name
5120233Smckusickparameter points to memory not in a valid part of the
5220233Smckusickprocess address space.
5347208Scael.El
5447208Scael.Sh SEE ALSO
5547208Scael.Xr accept 2 ,
5647208Scael.Xr bind 2 ,
5747208Scael.Xr socket 2 ,
5847208Scael.Xr getsockname 2
5947208Scael.Sh HISTORY
6047208ScaelThe
6147208Scael.Nm
6247208Scaelfunction call appeared in
6347208Scael.Bx 4.2 .
64