summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/getsockname.2
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/sys/getsockname.2')
-rw-r--r--lib/libc/sys/getsockname.229
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/libc/sys/getsockname.2 b/lib/libc/sys/getsockname.2
index d56e404..bbd9f93 100644
--- a/lib/libc/sys/getsockname.2
+++ b/lib/libc/sys/getsockname.2
@@ -38,6 +38,8 @@
.Nm getsockname
.Nd get socket name
.Sh SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <sys/socket.h>
.Ft int
.Fn getsockname "int s" "struct sockaddr *name" "int *namelen"
.Sh DESCRIPTION
@@ -51,7 +53,29 @@ the amount of space pointed to by
.Fa name .
On return it contains the actual size of the name
returned (in bytes).
-.Sh DIAGNOSTICS
+.Sh IMPLEMENTATION NOTES
+.Pp
+In the non-threaded library
+.Fn getsockname
+is implemented as the
+.Va getsockname
+syscall.
+.Pp
+In the threaded library, the
+.Va getsockname
+syscall is assembled to
+.Fn _thread_sys_getsockname
+and
+.Fn getsockname
+is implemented as a function which locks
+.Va fd
+for read and write, then calls
+.Fn _thread_sys_getsockname .
+Before returning,
+.Fn getsockname
+unlocks
+.Va fd .
+.Sh RETURN VALUES
A 0 is returned if the call succeeds, -1 if it fails.
.Sh ERRORS
The call succeeds unless:
@@ -75,6 +99,7 @@ process address space.
.El
.Sh SEE ALSO
.Xr bind 2 ,
+.Xr getpeername 2 ,
.Xr socket 2
.Sh BUGS
Names bound to sockets in the UNIX domain are inaccessible;
@@ -82,6 +107,6 @@ Names bound to sockets in the UNIX domain are inaccessible;
returns a zero length name.
.Sh HISTORY
The
-.Nm
+.Fn getsockname
function call appeared in
.Bx 4.2 .
OpenPOWER on IntegriCloud