~ubuntu-branches/ubuntu/precise/manpages-posix/precise

1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
2
.TH "BIND" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
3
.\" bind 
4
.SH NAME
5
bind \- bind a name to a socket
6
.SH SYNOPSIS
7
.LP
8
\fB#include <sys/socket.h>
9
.br
10
.sp
11
int bind(int\fP \fIsocket\fP\fB, const struct sockaddr *\fP\fIaddress\fP\fB,
12
.br
13
\ \ \ \ \ \  socklen_t\fP \fIaddress_len\fP\fB);
14
.br
15
\fP
16
.SH DESCRIPTION
17
.LP
18
The \fIbind\fP() function shall assign a local socket address \fIaddress\fP
19
to a socket identified by descriptor \fIsocket\fP
20
that has no local socket address assigned. Sockets created with the
21
\fIsocket\fP() function
22
are initially unnamed; they are identified only by their address family.
23
.LP
24
The \fIbind\fP() function takes the following arguments:
25
.TP 7
26
\fIsocket\fP
27
Specifies the file descriptor of the socket to be bound.
28
.TP 7
29
\fIaddress\fP
30
Points to a \fBsockaddr\fP structure containing the address to be
31
bound to the socket. The length and format of the address
32
depend on the address family of the socket.
33
.TP 7
34
\fIaddress_len\fP
35
Specifies the length of the \fBsockaddr\fP structure pointed to by
36
the \fIaddress\fP argument.
37
.sp
38
.LP
39
The socket specified by \fIsocket\fP may require the process to have
40
appropriate privileges to use the \fIbind\fP()
41
function.
42
.SH RETURN VALUE
43
.LP
44
Upon successful completion, \fIbind\fP() shall return 0; otherwise,
45
-1 shall be returned and \fIerrno\fP set to indicate the
46
error.
47
.SH ERRORS
48
.LP
49
The \fIbind\fP() function shall fail if:
50
.TP 7
51
.B EADDRINUSE
52
The specified address is already in use.
53
.TP 7
54
.B EADDRNOTAVAIL
55
The specified address is not available from the local machine.
56
.TP 7
57
.B EAFNOSUPPORT
58
The specified address is not a valid address for the address family
59
of the specified socket.
60
.TP 7
61
.B EBADF
62
The \fIsocket\fP argument is not a valid file descriptor.
63
.TP 7
64
.B EINVAL
65
The socket is already bound to an address, and the protocol does not
66
support binding to a new address; or the socket has been
67
shut down.
68
.TP 7
69
.B ENOTSOCK
70
The \fIsocket\fP argument does not refer to a socket.
71
.TP 7
72
.B EOPNOTSUPP
73
The socket type of the specified socket does not support binding to
74
an address.
75
.sp
76
.LP
77
If the address family of the socket is AF_UNIX, then \fIbind\fP()
78
shall fail if:
79
.TP 7
80
.B EACCES
81
A component of the path prefix denies search permission, or the requested
82
name requires writing in a directory with a mode that
83
denies write permission.
84
.TP 7
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
85
.B EDESTADDRREQ \fRor\fP EISDIR
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
86
The \fIaddress\fP argument is a null pointer.
87
.TP 7
88
.B EIO
89
An I/O error occurred.
90
.TP 7
91
.B ELOOP
92
A loop exists in symbolic links encountered during resolution of the
93
pathname in \fIaddress\fP.
94
.TP 7
95
.B ENAMETOOLONG
96
A component of a pathname exceeded {NAME_MAX} characters, or an entire
97
pathname exceeded {PATH_MAX} characters.
98
.TP 7
99
.B ENOENT
100
A component of the pathname does not name an existing file or the
101
pathname is an empty string.
102
.TP 7
103
.B ENOTDIR
104
A component of the path prefix of the pathname in \fIaddress\fP is
105
not a directory.
106
.TP 7
107
.B EROFS
108
The name would reside on a read-only file system.
109
.sp
110
.LP
111
The \fIbind\fP() function may fail if:
112
.TP 7
113
.B EACCES
114
The specified address is protected and the current user does not have
115
permission to bind to it.
116
.TP 7
117
.B EINVAL
118
The \fIaddress_len\fP argument is not a valid length for the address
119
family.
120
.TP 7
121
.B EISCONN
122
The socket is already connected.
123
.TP 7
124
.B ELOOP
125
More than {SYMLOOP_MAX} symbolic links were encountered during resolution
126
of the pathname in \fIaddress\fP.
127
.TP 7
128
.B ENAMETOOLONG
129
Pathname resolution of a symbolic link produced an intermediate result
130
whose length exceeds {PATH_MAX}.
131
.TP 7
132
.B ENOBUFS
133
Insufficient resources were available to complete the call.
134
.sp
135
.LP
136
\fIThe following sections are informative.\fP
137
.SH EXAMPLES
138
.LP
139
None.
140
.SH APPLICATION USAGE
141
.LP
142
An application program can retrieve the assigned socket name with
143
the \fIgetsockname\fP() function.
144
.SH RATIONALE
145
.LP
146
None.
147
.SH FUTURE DIRECTIONS
148
.LP
149
None.
150
.SH SEE ALSO
151
.LP
152
\fIconnect\fP() , \fIgetsockname\fP() , \fIlisten\fP() , \fIsocket\fP()
153
, the Base Definitions volume of
154
IEEE\ Std\ 1003.1-2001, \fI<sys/socket.h>\fP
155
.SH COPYRIGHT
156
Portions of this text are reprinted and reproduced in electronic form
157
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
158
-- Portable Operating System Interface (POSIX), The Open Group Base
159
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
160
Electrical and Electronics Engineers, Inc and The Open Group. In the
161
event of any discrepancy between this version and the original IEEE and
162
The Open Group Standard, the original IEEE and The Open Group Standard
163
is the referee document. The original Standard can be obtained online at
164
http://www.opengroup.org/unix/online.html .