]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/getsockname.2
sync
[thirdparty/man-pages.git] / man2 / getsockname.2
CommitLineData
fea681da
MK
1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)getsockname.2 6.4 (Berkeley) 3/10/91
33.\"
34.\" Modified Sat Jul 24 16:30:29 1993 by Rik Faith <faith@cs.unc.edu>
35.\" Modified Tue Oct 22 00:22:35 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
36.\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer <aeb@cwi.nl>
37.\"
38.TH GETSOCKNAME 2 1993-07-24 "BSD Man Page" "Linux Programmer's Manual"
39.SH NAME
40getsockname \- get socket name
41.SH SYNOPSIS
42.nf
43.B #include <sys/socket.h>
44.sp
45.BI "int getsockname(int " s ", struct sockaddr *" name ", socklen_t *" namelen );
46.fi
47.SH DESCRIPTION
7145b9a9 48.BR getsockname ()
fea681da
MK
49returns the current
50.I name
51for the specified socket. The
52.I namelen
53parameter should be initialized to indicate
54the amount of space pointed to by
55.IR name .
56On return it contains the actual size of the name
57returned (in bytes).
58.SH "RETURN VALUE"
59On success, zero is returned. On error, \-1 is returned, and
60.I errno
61is set appropriately.
62.SH ERRORS
63.TP
64.B EBADF
65The argument
66.I s
67is not a valid descriptor.
68.TP
69.B EFAULT
70The
71.I name
72parameter points to memory not in a valid part of the
73process address space.
74.TP
16c892d3
MK
75.B EINVAL
76.I namelen
77is invalid (e.g., is negative).
78.TP
fea681da
MK
79.B ENOBUFS
80Insufficient resources were available in the system
81to perform the operation.
82.TP
83.B ENOTSOCK
84The argument
85.I s
86is a file, not a socket.
87.SH "CONFORMING TO"
88SVr4, 4.4BSD (the
e511ffb6 89.BR getsockname ()
97c1eac8
MK
90function call appeared in 4.2BSD), POSIX.1-2001.
91.\" SVr4 documents additional ENOMEM
92.\" and ENOSR error codes.
fea681da
MK
93.SH NOTE
94The third argument of
e511ffb6 95.BR getsockname ()
b14d4aa5 96is in reality an `int *' (and this is what 4.x BSD and libc4 and libc5 have).
fea681da
MK
97Some POSIX confusion resulted in the present socklen_t, also used by glibc.
98See also
99.BR accept (2).
100.SH "SEE ALSO"
101.BR bind (2),
102.BR socket (2)