-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\" Portions extracted from /usr/include/sys/socket.h, which does not have
.\" any authorship information in it. It is probably available under the GPL.
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\"
.\" Other portions are from the 6.9 (Berkeley) 3/10/91 man page:
.\" Copyright (c) 1983 The Regents of the University of California.
.\" All rights reserved.
.\"
+.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
+.\" %%%LICENSE_END
.\"
.\" Modified Mon Oct 21 23:05:29 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 1998 by Andi Kleen
.\" $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-12-28 "Linux" "Linux Programmer's Manual"
+.TH BIND 2 2014-08-19 "Linux" "Linux Programmer's Manual"
.SH NAME
bind \- bind a name to a socket
.SH SYNOPSIS
.BR socket (2),
it exists in a name space (address family) but has no address assigned to it.
.BR bind ()
-assigns the address specified to by
+assigns the address specified by
.I addr
to the socket referred to by the file descriptor
.IR sockfd .
.I addr
in order to avoid compiler warnings.
See EXAMPLE below.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
On success, zero is returned.
On error, \-1 is returned, and
.I errno
.B EADDRINUSE
The given address is already in use.
.TP
+.B EADDRINUSE
+(Internet domain sockets)
+The port number was specified as zero in the socket address structure,
+but, upon attempting to bind to an ephemeral port,
+it was determined that all port numbers in the ephemeral port range
+are currently in use.
+See the discussion of
+.I /proc/sys/net/ipv4/ip_local_port_range
+.BR ip (7).
+.TP
+.TP
.B EBADF
.I sockfd
is not a valid descriptor.
.\" This may change in the future: see
.\" .I linux/unix/sock.c for details.
.TP
+.B EINVAL
+.I addrlen
+is wrong, or
+.I addr
+is not a valid address for this socket's domain.
+.TP
.B ENOTSOCK
.I sockfd
is a descriptor for a file, not a socket.
.PP
-The following errors are specific to Unix domain
+The following errors are specific to UNIX domain
.RB ( AF_UNIX )
sockets:
.TP
.I addr
points outside the user's accessible address space.
.TP
-.B EINVAL
-The
-.I addrlen
-is wrong, or the socket was not in the
-.B AF_UNIX
-family.
-.TP
.B ELOOP
Too many symbolic links were encountered in resolving
.IR addr .
A component of the path prefix is not a directory.
.TP
.B EROFS
-The socket inode would reside on a read-only file system.
-.SH "CONFORMING TO"
+The socket inode would reside on a read-only filesystem.
+.SH CONFORMING TO
SVr4, 4.4BSD, POSIX.1-2001
.RB ( bind ()
first appeared in 4.2BSD).
.\" .B EIO
.\" and
.\" .B EISDIR
-.\" Unix-domain error conditions.
+.\" UNIX-domain error conditions.
.SH NOTES
POSIX.1-2001 does not require the inclusion of
.IR <sys/types.h> ,
.BR accept (2).
.SH BUGS
The transparent proxy options are not described.
-.\" FIXME What *are* transparent proxy options?
+.\" FIXME Document transparent proxy options
.SH EXAMPLE
An example of the use of
.BR bind ()
with Internet domain sockets can be found in
.BR getaddrinfo (3).
-The following example shows how to bind a stream socket in the Unix
+The following example shows how to bind a stream socket in the UNIX
.RB ( AF_UNIX )
domain, and accept connections:
.\" listen.7 refers to this example.
should be deleted using unlink(2) or remove(3) */
}
.fi
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR accept (2),
.BR connect (2),
.BR getsockname (2),
.BR path_resolution (7),
.BR socket (7),
.BR unix (7)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.