1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" SPDX-License-Identifier: BSD-4-Clause-UC
6 .\" @(#)getsockname.2 6.4 (Berkeley) 3/10/91
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>
12 .TH getsockname 2 (date) "Linux man-pages (unreleased)"
14 getsockname \- get socket name
17 .RI ( libc ", " \-lc )
20 .B #include <sys/socket.h>
22 .BI "int getsockname(int " sockfd ", struct sockaddr *restrict " addr ,
23 .BI " socklen_t *restrict " addrlen );
27 returns the current address to which the socket
29 is bound, in the buffer pointed to by
33 argument should be initialized to indicate
34 the amount of space (in bytes) pointed to by
36 On return it contains the actual size of the socket address.
38 The returned address is truncated if the buffer provided is too small;
41 will return a value greater than was supplied to the call.
43 On success, zero is returned.
44 On error, \-1 is returned, and
46 is set to indicate the error.
52 is not a valid file descriptor.
57 argument points to memory not in a valid part of the
58 process address space.
62 is invalid (e.g., is negative).
65 Insufficient resources were available in the system
66 to perform the operation.
71 does not refer to a socket.
73 POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD
75 first appeared in 4.2BSD).
76 .\" SVr4 documents additional ENOMEM
77 .\" and ENOSR error codes.