readlink.2 rename.2 unlink.2
[unix-history] / usr / src / lib / libc / sys / getsockname.2
CommitLineData
931b8415 1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
da268306 2.\" All rights reserved.
b17ac36d 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
da268306 5.\"
931b8415 6.\" @(#)getsockname.2 6.4 (Berkeley) %G%
b17ac36d 7.\"
931b8415
CL
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
b17ac36d 19returns the current
931b8415 20.Fa name
b17ac36d 21for the specified socket. The
931b8415 22.Fa namelen
b17ac36d
KM
23parameter should be initialized to indicate
24the amount of space pointed to by
931b8415 25.Fa name .
b17ac36d
KM
26On return it contains the actual size of the name
27returned (in bytes).
931b8415
CL
28.Sh DIAGNOSTICS
29A 0 is returned if the call succeeds, -1 if it fails.
30.Sh ERRORS
b17ac36d 31The call succeeds unless:
931b8415
CL
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
b17ac36d
KM
42Insufficient resources were available in the system
43to perform the operation.
931b8415 44.It Bq Er EFAULT
b17ac36d 45The
931b8415 46.Fa name
b17ac36d
KM
47parameter points to memory not in a valid part of the
48process address space.
931b8415
CL
49.El
50.Sh SEE ALSO
51.Xr bind 2 ,
52.Xr socket 2
53.Sh BUGS
b17ac36d 54Names bound to sockets in the UNIX domain are inaccessible;
931b8415 55.Xr getsockname
b17ac36d 56returns a zero length name.
931b8415
CL
57.Sh HISTORY
58The
59.Nm
60function call appeared in
61.Bx 4.2 .