xref: /original-bsd/lib/libc/sys/getsockname.2 (revision c3e32dec)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)getsockname.2	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt GETSOCKNAME 2
10.Os BSD 4.2
11.Sh NAME
12.Nm getsockname
13.Nd get socket name
14.Sh SYNOPSIS
15.Ft int
16.Fn getsockname "int s" "struct sockaddr *name" "int *namelen"
17.Sh DESCRIPTION
18.Fn Getsockname
19returns the current
20.Fa name
21for the specified socket.  The
22.Fa namelen
23parameter should be initialized to indicate
24the amount of space pointed to by
25.Fa name .
26On return it contains the actual size of the name
27returned (in bytes).
28.Sh DIAGNOSTICS
29A 0 is returned if the call succeeds, -1 if it fails.
30.Sh ERRORS
31The call succeeds unless:
32.Bl -tag -width ENOTSOCKAA
33.It Bq Er EBADF
34The argument
35.Fa s
36is not a valid descriptor.
37.It Bq Er ENOTSOCK
38The argument
39.Fa s
40is a file, not a socket.
41.It Bq Er ENOBUFS
42Insufficient resources were available in the system
43to perform the operation.
44.It Bq Er EFAULT
45The
46.Fa name
47parameter points to memory not in a valid part of the
48process address space.
49.El
50.Sh SEE ALSO
51.Xr bind 2 ,
52.Xr socket 2
53.Sh BUGS
54Names bound to sockets in the UNIX domain are inaccessible;
55.Xr getsockname
56returns a zero length name.
57.Sh HISTORY
58The
59.Nm
60function call appeared in
61.Bx 4.2 .
62