flag fields are u_int's
[unix-history] / usr / src / lib / libc / sys / getpeername.2
CommitLineData
931b8415 1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
da268306 2.\" All rights reserved.
c93f2ba8 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
da268306 5.\"
931b8415 6.\" @(#)getpeername.2 6.5 (Berkeley) %G%
c93f2ba8 7.\"
931b8415
CL
8.Dd
9.Dt GETPEERNAME 2
10.Os BSD 4.2
11.Sh NAME
12.Nm getpeername
13.Nd get name of connected peer
14.Sh SYNOPSIS
15.Ft int
16.Fn getpeername "int s" "struct sockaddr *name" "int *namelen"
17.Sh DESCRIPTION
18.Fn Getpeername
c93f2ba8
KM
19returns the name of the peer connected to
20socket
931b8415 21.Fa s .
c93f2ba8 22The
931b8415 23.Fa namelen
c93f2ba8
KM
24parameter should be initialized to indicate
25the amount of space pointed to by
931b8415 26.Fa name .
c93f2ba8
KM
27On return it contains the actual size of the name
28returned (in bytes).
e4589241 29The name is truncated if the buffer provided is too small.
931b8415
CL
30.Sh DIAGNOSTICS
31A 0 is returned if the call succeeds, -1 if it fails.
32.Sh ERRORS
c93f2ba8 33The call succeeds unless:
931b8415
CL
34.Bl -tag -width ENOTSOCKAA
35.It Bq Er EBADF
36The argument
37.Fa s
38is not a valid descriptor.
39.It Bq Er ENOTSOCK
40The argument
41.Fa s
42is a file, not a socket.
43.It Bq Er ENOTCONN
c93f2ba8 44The socket is not connected.
931b8415 45.It Bq Er ENOBUFS
c93f2ba8
KM
46Insufficient resources were available in the system
47to perform the operation.
931b8415 48.It Bq Er EFAULT
c93f2ba8 49The
931b8415 50.Fa name
c93f2ba8
KM
51parameter points to memory not in a valid part of the
52process address space.
931b8415
CL
53.El
54.Sh SEE ALSO
55.Xr accept 2 ,
56.Xr bind 2 ,
57.Xr socket 2 ,
58.Xr getsockname 2
59.Sh HISTORY
60The
61.Nm
62function call appeared in
63.Bx 4.2 .