tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man2 / getsockname.2
blob331dadaeea757621c697b610535b6be42905c10a
1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" SPDX-License-Identifier: BSD-4-Clause-UC
5 .\"
6 .\"     @(#)getsockname.2       6.4 (Berkeley) 3/10/91
7 .\"
8 .\" Modified Sat Jul 24 16:30:29 1993 by Rik Faith <faith@cs.unc.edu>
9 .\" Modified Tue Oct 22 00:22:35 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
10 .\" Modified Sun Mar 28 21:26:46 1999 by Andries Brouwer <aeb@cwi.nl>
11 .\"
12 .TH getsockname 2 (date) "Linux man-pages (unreleased)"
13 .SH NAME
14 getsockname \- get socket name
15 .SH LIBRARY
16 Standard C library
17 .RI ( libc ", " \-lc )
18 .SH SYNOPSIS
19 .nf
20 .B #include <sys/socket.h>
21 .PP
22 .BI "int getsockname(int " sockfd ", struct sockaddr *restrict " addr ,
23 .BI "                socklen_t *restrict " addrlen );
24 .fi
25 .SH DESCRIPTION
26 .BR getsockname ()
27 returns the current address to which the socket
28 .I sockfd
29 is bound, in the buffer pointed to by
30 .IR addr .
31 The
32 .I addrlen
33 argument should be initialized to indicate
34 the amount of space (in bytes) pointed to by
35 .IR addr .
36 On return it contains the actual size of the socket address.
37 .PP
38 The returned address is truncated if the buffer provided is too small;
39 in this case,
40 .I addrlen
41 will return a value greater than was supplied to the call.
42 .SH RETURN VALUE
43 On success, zero is returned.
44 On error, \-1 is returned, and
45 .I errno
46 is set to indicate the error.
47 .SH ERRORS
48 .TP
49 .B EBADF
50 The argument
51 .I sockfd
52 is not a valid file descriptor.
53 .TP
54 .B EFAULT
55 The
56 .I addr
57 argument points to memory not in a valid part of the
58 process address space.
59 .TP
60 .B EINVAL
61 .I addrlen
62 is invalid (e.g., is negative).
63 .TP
64 .B ENOBUFS
65 Insufficient resources were available in the system
66 to perform the operation.
67 .TP
68 .B ENOTSOCK
69 The file descriptor
70 .I sockfd
71 does not refer to a socket.
72 .SH STANDARDS
73 POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD
74 .RB ( getsockname ()
75 first appeared in 4.2BSD).
76 .\" SVr4 documents additional ENOMEM
77 .\" and ENOSR error codes.
78 .SH NOTES
79 For background on the
80 .I socklen_t
81 type, see
82 .BR accept (2).
83 .SH SEE ALSO
84 .BR bind (2),
85 .BR socket (2),
86 .BR getifaddrs (3),
87 .BR ip (7),
88 .BR socket (7),
89 .BR unix (7)