Minor rewrites

This commit is contained in:
Michael Kerrisk 2007-12-27 14:37:14 +00:00
parent 938576af95
commit 791ce3b986
1 changed files with 22 additions and 21 deletions

View File

@ -63,7 +63,7 @@
.\" $Id: bind.2,v 1.3 1999/04/23 19:56:07 freitag Exp $
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.TH BIND 2 2007-06-08 "Linux" "Linux Programmer's Manual"
.TH BIND 2 2007-12-28 "Linux" "Linux Programmer's Manual"
.SH NAME
bind \- bind a name to a socket
.SH SYNOPSIS
@ -71,23 +71,22 @@ bind \- bind a name to a socket
.BR "#include <sys/types.h>" " /* See NOTES */"
.B #include <sys/socket.h>
.sp
.BI "int bind(int " sockfd ", const struct sockaddr *" my_addr ,
.BI "int bind(int " sockfd ", const struct sockaddr *" addr ,
.BI " socklen_t " addrlen );
.fi
.SH DESCRIPTION
.BR bind ()
gives the socket
.I sockfd
the local address
.IR my_addr .
.I my_addr
is
.I addrlen
bytes long.
Traditionally, this is called \(lqassigning a name to a socket.\(rq
When a socket is created with
.BR socket (2),
it exists in a name space (address family) but has no name assigned.
it exists in a name space (address family) but has no address assigned to it.
.BR bind ()
assigns the address specified to by
.I addr
to the socket referred to by the file descriptor
.IR sockfd .
.I addrlen
specifies the size, in bytes, of the address structure pointed to by
.IR addr .
Traditionally, this operation is called \(lqassigning a name to a socket\(rq.
.PP
It is normally necessary to assign a local address using
.BR bind ()
@ -128,7 +127,7 @@ see
.BR netlink (7).
The actual structure passed for the
.I my_addr
.I addr
argument will depend on the address family.
The
.I sockaddr
@ -145,7 +144,7 @@ struct sockaddr {
.in
The only purpose of this structure is to cast the structure
pointer passed in
.I my_addr
.I addr
in order to avoid compiler warnings.
See EXAMPLE below.
.SH "RETURN VALUE"
@ -156,6 +155,7 @@ is set appropriately.
.SH ERRORS
.TP
.B EACCES
.\" e.g., reserved port in AF_INET domain
The address is protected, and the user is not the superuser.
.TP
.B EADDRINUSE
@ -188,7 +188,7 @@ A nonexistent interface was requested or the requested
address was not local.
.TP
.B EFAULT
.I my_addr
.I addr
points outside the user's accessible address space.
.TP
.B EINVAL
@ -200,10 +200,10 @@ family.
.TP
.B ELOOP
Too many symbolic links were encountered in resolving
.IR my_addr .
.IR addr .
.TP
.B ENAMETOOLONG
.I my_addr
.I addr
is too long.
.TP
.B ENOENT
@ -218,9 +218,9 @@ A component of the path prefix is not a directory.
.B EROFS
The socket inode would reside on a read-only file system.
.SH "CONFORMING TO"
SVr4, 4.4BSD, POSIX.1-2001 (the
.BR bind ()
function first appeared in 4.2BSD).
SVr4, 4.4BSD, POSIX.1-2001
.RB ( bind ()
first appeared in 4.2BSD).
.\" SVr4 documents an additional
.\" .B ENOSR
.\" general error condition, and
@ -248,6 +248,7 @@ See also
.BR accept (2).
.SH BUGS
The transparent proxy options are not described.
.\" FIXME What *are* transparent proxy options?
.SH EXAMPLE
An example of the use of
.BR bind ()