1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man3xnet / bind.3xnet
blob45772c3ff81aafe7abc1c477eac1e373fa2865a5
1 '\" te
2 .\" Copyright (c) 1997, The Open Group. All Rights Reserved.
3 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 .\"  This notice shall appear on any product containing this material.
8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 .TH BIND 3XNET "Feb 20, 2003"
12 .SH NAME
13 bind \- bind a name to a socket
14 .SH SYNOPSIS
15 .LP
16 .nf
17 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lxnet\fR [ \fIlibrary\fR ... ]
18 #include <sys/socket.h>
20 \fBint\fR \fBbind\fR(\fBint\fR \fIsocket\fR, \fBconst struct sockaddr *\fR\fIaddress\fR,
21      \fBsocklen_t\fR \fIaddress_len\fR);
22 .fi
24 .SH DESCRIPTION
25 .sp
26 .LP
27 The \fBbind()\fR function assigns an \fIaddress\fR to an unnamed socket.
28 Sockets created with \fBsocket\fR(3XNET) function are initially unnamed. They
29 are identified only by their address family.
30 .sp
31 .LP
32 The function takes the following arguments:
33 .sp
34 .ne 2
35 .na
36 \fB\fIsocket\fR\fR
37 .ad
38 .RS 15n
39 Specifies the file descriptor of the socket to be bound.
40 .RE
42 .sp
43 .ne 2
44 .na
45 \fB\fIaddress\fR\fR
46 .ad
47 .RS 15n
48 Points to a \fBsockaddr\fR structure containing the address to be bound to the
49 socket.  The length and format of the address depend on the address family of
50 the socket.
51 .RE
53 .sp
54 .ne 2
55 .na
56 \fB\fIaddress_len\fR\fR
57 .ad
58 .RS 15n
59 Specifies the length of the \fBsockaddr\fR structure pointed to by the
60 \fIaddress\fR argument.
61 .RE
63 .sp
64 .LP
65 The socket in use may require the process to have appropriate privileges to use
66 the \fBbind()\fR function.
67 .SH USAGE
68 .sp
69 .LP
70 An application program can retrieve the assigned socket name with the
71 \fBgetsockname\fR(3XNET) function.
72 .SH RETURN VALUES
73 .sp
74 .LP
75 Upon successful completion, \fBbind()\fR returns 0.  Otherwise, \(mi1 is
76 returned and \fBerrno\fR is set to indicate the error.
77 .SH ERRORS
78 .sp
79 .LP
80 The \fBbind()\fR function will fail if:
81 .sp
82 .ne 2
83 .na
84 \fB\fBEADDRINUSE\fR\fR
85 .ad
86 .RS 17n
87 The specified address is already in use.
88 .RE
90 .sp
91 .ne 2
92 .na
93 \fB\fBEADDRNOTAVAIL\fR\fR
94 .ad
95 .RS 17n
96 The specified address is not available from the local machine.
97 .RE
99 .sp
100 .ne 2
102 \fB\fBEAFNOSUPPORT\fR\fR
104 .RS 17n
105 The specified address is not a valid address for the address family of the
106 specified socket.
110 .ne 2
112 \fB\fBEBADF\fR\fR
114 .RS 17n
115 The \fIsocket\fR argument is not a valid file descriptor.
119 .ne 2
121 \fB\fBEFAULT\fR\fR
123 .RS 17n
124 The  \fIaddress\fR argument can not be accessed.
128 .ne 2
130 \fB\fBEINVAL\fR\fR
132 .RS 17n
133 The socket is already bound to an address, and the protocol does not support
134 binding to a new address; or the socket has been shut down.
138 .ne 2
140 \fB\fBENOTSOCK\fR\fR
142 .RS 17n
143 The \fIsocket\fR argument does not refer to a socket.
147 .ne 2
149 \fB\fBEOPNOTSUPP\fR\fR
151 .RS 17n
152 The socket type of the specified socket does not support binding to an address.
157 If the address family of the socket is AF_UNIX, then \fBbind()\fR will fail if:
159 .ne 2
161 \fB\fBEACCES\fR\fR
163 .RS 16n
164 A component of the path prefix denies search permission, or the requested name
165 requires writing in a directory with a mode that denies write permission.
169 .ne 2
171 \fB\fBEDESTADDRREQ\fR\fR
175 \fB\fBEISDIR\fR\fR
177 .RS 16n
178 The \fIaddress\fR argument is a null pointer.
182 .ne 2
184 \fB\fBEIO\fR\fR
186 .RS 16n
187 An I/O error occurred.
191 .ne 2
193 \fB\fBELOOP\fR\fR
195 .RS 16n
196 Too many symbolic links were encountered in translating the pathname in
197 \fIaddress.\fR
201 .ne 2
203 \fB\fBENAMETOOLONG\fR\fR
205 .RS 16n
206 A component of a pathname exceeded \fINAME_MAX\fR characters, or an entire
207 pathname exceeded \fIPATH_MAX\fR characters.
211 .ne 2
213 \fB\fBENOENT\fR\fR
215 .RS 16n
216 A component of the pathname does not name an existing file or the pathname is
217 an empty string.
221 .ne 2
223 \fB\fBENOTDIR\fR\fR
225 .RS 16n
226 A component of the path prefix of the pathname in \fIaddress\fR is not a
227 directory.
231 .ne 2
233 \fB\fBEROFS\fR\fR
235 .RS 16n
236 The name would reside on a read-only filesystem.
241 The \fBbind()\fR function may fail if:
243 .ne 2
245 \fB\fBEACCES\fR\fR
247 .RS 16n
248 The specified address is protected, and \fB{PRIV_NET_PRIVADOR}\fR is not
249 asserted in the effective set of the current process.
253 .ne 2
255 \fB\fBEINVAL\fR\fR
257 .RS 16n
258 The \fIaddress_len\fR argument is not a valid length for the address family.
262 .ne 2
264 \fB\fBEISCONN\fR\fR
266 .RS 16n
267 The socket is already connected.
271 .ne 2
273 \fB\fBENAMETOOLONG\fR\fR
275 .RS 16n
276 Pathname resolution of a symbolic link produced an intermediate result whose
277 length exceeds \fIPATH_MAX\fR.
281 .ne 2
283 \fB\fBENOBUFS\fR\fR
285 .RS 16n
286 Insufficient resources were available to complete the call.
290 .ne 2
292 \fB\fBENOSR\fR\fR
294 .RS 16n
295 There were insufficient STREAMS resources for the operation to complete.
298 .SH ATTRIBUTES
301 See \fBattributes\fR(5) for descriptions of the following attributes:
306 box;
307 c | c
308 l | l .
309 ATTRIBUTE TYPE  ATTRIBUTE VALUE
311 Interface Stability     Standard
313 MT-Level        MT-Safe
316 .SH SEE ALSO
319 \fBconnect\fR(3XNET), \fBgetsockname\fR(3XNET), \fBlisten\fR(3XNET),
320 \fBsocket\fR(3XNET), \fBattributes\fR(5), \fBprivileges\fR(5),
321 \fBstandards\fR(5)