]>
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 | .\" | |
c4e7b714 | 38 | .TH GETSOCKNAME 2 2008-12-03 "Linux" "Linux Programmer's Manual" |
fea681da MK |
39 | .SH NAME |
40 | getsockname \- get socket name | |
41 | .SH SYNOPSIS | |
42 | .nf | |
43 | .B #include <sys/socket.h> | |
44 | .sp | |
a2b8b6d6 MK |
45 | .BI "int getsockname(int " sockfd ", struct sockaddr *" addr \ |
46 | ", socklen_t *" addrlen ); | |
fea681da MK |
47 | .fi |
48 | .SH DESCRIPTION | |
7145b9a9 | 49 | .BR getsockname () |
3c19f5ed MK |
50 | returns the current address to which the socket |
51 | .I sockfd | |
52 | is bound, in the buffer pointed to by | |
a2b8b6d6 | 53 | .IR addr . |
c13182ef | 54 | The |
a2b8b6d6 | 55 | .I addrlen |
c4bb193f | 56 | argument should be initialized to indicate |
f7c494fb | 57 | the amount of space (in bytes) pointed to by |
a2b8b6d6 | 58 | .IR addr . |
f7c494fb MK |
59 | On return it contains the actual size of the socket address. |
60 | ||
61 | The returned address is truncated if the buffer provided is too small; | |
62 | in this case, | |
a2b8b6d6 | 63 | .I addrlen |
f7c494fb | 64 | will return a value greater than was supplied to the call. |
fea681da | 65 | .SH "RETURN VALUE" |
c13182ef MK |
66 | On success, zero is returned. |
67 | On error, \-1 is returned, and | |
fea681da MK |
68 | .I errno |
69 | is set appropriately. | |
70 | .SH ERRORS | |
71 | .TP | |
72 | .B EBADF | |
73 | The argument | |
74 | .I s | |
75 | is not a valid descriptor. | |
76 | .TP | |
77 | .B EFAULT | |
c13182ef | 78 | The |
a2b8b6d6 | 79 | .I addr |
c4bb193f | 80 | argument points to memory not in a valid part of the |
fea681da MK |
81 | process address space. |
82 | .TP | |
16c892d3 | 83 | .B EINVAL |
a2b8b6d6 | 84 | .I addrlen |
16c892d3 MK |
85 | is invalid (e.g., is negative). |
86 | .TP | |
fea681da MK |
87 | .B ENOBUFS |
88 | Insufficient resources were available in the system | |
89 | to perform the operation. | |
90 | .TP | |
91 | .B ENOTSOCK | |
92 | The argument | |
93 | .I s | |
94 | is a file, not a socket. | |
95 | .SH "CONFORMING TO" | |
96 | SVr4, 4.4BSD (the | |
e511ffb6 | 97 | .BR getsockname () |
97c1eac8 MK |
98 | function call appeared in 4.2BSD), POSIX.1-2001. |
99 | .\" SVr4 documents additional ENOMEM | |
c13182ef | 100 | .\" and ENOSR error codes. |
19c98696 | 101 | .SH NOTES |
c13182ef | 102 | The third argument of |
e511ffb6 | 103 | .BR getsockname () |
2b0fa182 MK |
104 | is in reality an \fIint *\fP |
105 | (and this is what 4.x BSD and libc4 and libc5 have). | |
106 | Some POSIX confusion resulted in the present \fIsocklen_t\fP, | |
107 | also used by glibc. | |
fea681da MK |
108 | See also |
109 | .BR accept (2). | |
110 | .SH "SEE ALSO" | |
111 | .BR bind (2), | |
ecae8a08 MK |
112 | .BR socket (2), |
113 | .BR ip (7), | |
5dfedcae | 114 | .BR socket (7), |
ecae8a08 | 115 | .BR unix (7) |