BSD 4_3_Reno release
[unix-history] / usr / src / lib / libc / sys / getpeername.2
CommitLineData
da268306
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
c93f2ba8 3.\"
1c15e888
C
4.\" Redistribution and use in source and binary forms are permitted provided
5.\" that: (1) source distributions retain this entire copyright notice and
6.\" comment, and (2) distributions including binaries display the following
7.\" acknowledgement: ``This product includes software developed by the
8.\" University of California, Berkeley and its contributors'' in the
9.\" documentation or other materials provided with the distribution and in
10.\" all advertising materials mentioning features or use of this software.
11.\" Neither the name of the University nor the names of its contributors may
12.\" be used to endorse or promote products derived from this software without
13.\" specific prior written permission.
14.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
da268306 17.\"
1c15e888 18.\" @(#)getpeername.2 6.4 (Berkeley) 6/23/90
c93f2ba8 19.\"
1c15e888 20.TH GETPEERNAME 2 "June 23, 1990"
c93f2ba8
KM
21.UC 5
22.SH NAME
23getpeername \- get name of connected peer
24.SH SYNOPSIS
25.nf
26.PP
27.ft B
28getpeername(s, name, namelen)
29int s;
30struct sockaddr *name;
31int *namelen;
32.fi
33.SH DESCRIPTION
34.I Getpeername
35returns the name of the peer connected to
36socket
37.IR s .
38The
39.I namelen
40parameter should be initialized to indicate
41the amount of space pointed to by
42.IR name .
43On return it contains the actual size of the name
44returned (in bytes).
e4589241 45The name is truncated if the buffer provided is too small.
c93f2ba8
KM
46.SH DIAGNOSTICS
47A 0 is returned if the call succeeds, \-1 if it fails.
48.SH ERRORS
49The call succeeds unless:
50.TP 15
51[EBADF]
52The argument \fIs\fP is not a valid descriptor.
53.TP 15
54[ENOTSOCK]
55The argument \fIs\fP is a file, not a socket.
56.TP 15
57[ENOTCONN]
58The socket is not connected.
59.TP 15
60[ENOBUFS]
61Insufficient resources were available in the system
62to perform the operation.
63.TP 15
64[EFAULT]
65The
66.I name
67parameter points to memory not in a valid part of the
68process address space.
69.SH "SEE ALSO"
e4589241 70accept(2), bind(2), socket(2), getsockname(2)