]>
Commit | Line | Data |
---|---|---|
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 | |
40 | getsockname \- 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 () |
c13182ef | 49 | returns the current |
fea681da | 50 | .I name |
c13182ef MK |
51 | for the specified socket. |
52 | The | |
fea681da MK |
53 | .I namelen |
54 | parameter should be initialized to indicate | |
55 | the amount of space pointed to by | |
56 | .IR name . | |
57 | On return it contains the actual size of the name | |
58 | returned (in bytes). | |
59 | .SH "RETURN VALUE" | |
c13182ef MK |
60 | On success, zero is returned. |
61 | On error, \-1 is returned, and | |
fea681da MK |
62 | .I errno |
63 | is set appropriately. | |
64 | .SH ERRORS | |
65 | .TP | |
66 | .B EBADF | |
67 | The argument | |
68 | .I s | |
69 | is not a valid descriptor. | |
70 | .TP | |
71 | .B EFAULT | |
c13182ef | 72 | The |
fea681da MK |
73 | .I name |
74 | parameter points to memory not in a valid part of the | |
75 | process address space. | |
76 | .TP | |
16c892d3 MK |
77 | .B EINVAL |
78 | .I namelen | |
79 | is invalid (e.g., is negative). | |
80 | .TP | |
fea681da MK |
81 | .B ENOBUFS |
82 | Insufficient resources were available in the system | |
83 | to perform the operation. | |
84 | .TP | |
85 | .B ENOTSOCK | |
86 | The argument | |
87 | .I s | |
88 | is a file, not a socket. | |
89 | .SH "CONFORMING TO" | |
90 | SVr4, 4.4BSD (the | |
e511ffb6 | 91 | .BR getsockname () |
97c1eac8 MK |
92 | function call appeared in 4.2BSD), POSIX.1-2001. |
93 | .\" SVr4 documents additional ENOMEM | |
c13182ef | 94 | .\" and ENOSR error codes. |
fea681da | 95 | .SH NOTE |
c13182ef | 96 | The third argument of |
e511ffb6 | 97 | .BR getsockname () |
b14d4aa5 | 98 | is in reality an `int *' (and this is what 4.x BSD and libc4 and libc5 have). |
fea681da MK |
99 | Some POSIX confusion resulted in the present socklen_t, also used by glibc. |
100 | See also | |
101 | .BR accept (2). | |
102 | .SH "SEE ALSO" | |
103 | .BR bind (2), | |
104 | .BR socket (2) |