summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/bind.2
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/sys/bind.2')
-rw-r--r--lib/libc/sys/bind.232
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/libc/sys/bind.2 b/lib/libc/sys/bind.2
index 18512e2..ce6ca0c 100644
--- a/lib/libc/sys/bind.2
+++ b/lib/libc/sys/bind.2
@@ -41,7 +41,7 @@
.Fd #include <sys/types.h>
.Fd #include <sys/socket.h>
.Ft int
-.Fn bind "int s" "struct sockaddr *name" "int namelen"
+.Fn bind "int s" "const struct sockaddr *name" "int namelen"
.Sh DESCRIPTION
.Fn Bind
assigns a name to an unnamed socket.
@@ -62,6 +62,28 @@ needed (using
.Pp
The rules used in name binding vary between communication domains.
Consult the manual entries in section 4 for detailed information.
+.Sh IMPLEMENTATION NOTES
+.Pp
+In the non-threaded library
+.Fn bind
+is implemented as the
+.Va bind
+syscall.
+.Pp
+In the threaded library, the
+.Va bind
+syscall is assembled to
+.Fn _thread_sys_bind
+and
+.Fn bind
+is implemented as a function which locks
+.Va s
+for read and write, then calls
+.Fn _thread_sys_bind .
+Before returning,
+.Fn bind
+unlocks
+.Va s .
.Sh RETURN VALUES
If the bind is successful, a 0 value is returned.
A return value of -1 indicates an error, which is
@@ -82,8 +104,6 @@ is not a socket.
The specified address is not available from the local machine.
.It Bq Er EADDRINUSE
The specified address is already in use.
-.It Bq Er EINVAL
-The socket is already bound to an address.
.It Bq Er EACCES
The requested address is protected, and the current user
has inadequate permission to access it.
@@ -116,11 +136,11 @@ An empty pathname was specified.
.El
.Sh SEE ALSO
.Xr connect 2 ,
+.Xr getsockname 2 ,
.Xr listen 2 ,
-.Xr socket 2 ,
-.Xr getsockname 2
+.Xr socket 2
.Sh HISTORY
The
-.Nm
+.Fn bind
function call appeared in
.Bx 4.2 .
OpenPOWER on IntegriCloud