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"
13 bind \- bind a name to a socket
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);
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.
32 The function takes the following arguments:
39 Specifies the file descriptor of the socket to be bound.
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
56 \fB\fIaddress_len\fR\fR
59 Specifies the length of the \fBsockaddr\fR structure pointed to by the
60 \fIaddress\fR argument.
65 The socket in use may require the process to have appropriate privileges to use
66 the \fBbind()\fR function.
70 An application program can retrieve the assigned socket name with the
71 \fBgetsockname\fR(3XNET) function.
75 Upon successful completion, \fBbind()\fR returns 0. Otherwise, \(mi1 is
76 returned and \fBerrno\fR is set to indicate the error.
80 The \fBbind()\fR function will fail if:
84 \fB\fBEADDRINUSE\fR\fR
87 The specified address is already in use.
93 \fB\fBEADDRNOTAVAIL\fR\fR
96 The specified address is not available from the local machine.
102 \fB\fBEAFNOSUPPORT\fR\fR
105 The specified address is not a valid address for the address family of the
115 The \fIsocket\fR argument is not a valid file descriptor.
124 The \fIaddress\fR argument can not be accessed.
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.
143 The \fIsocket\fR argument does not refer to a socket.
149 \fB\fBEOPNOTSUPP\fR\fR
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:
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.
171 \fB\fBEDESTADDRREQ\fR\fR
178 The \fIaddress\fR argument is a null pointer.
187 An I/O error occurred.
196 Too many symbolic links were encountered in translating the pathname in
203 \fB\fBENAMETOOLONG\fR\fR
206 A component of a pathname exceeded \fINAME_MAX\fR characters, or an entire
207 pathname exceeded \fIPATH_MAX\fR characters.
216 A component of the pathname does not name an existing file or the pathname is
226 A component of the path prefix of the pathname in \fIaddress\fR is not a
236 The name would reside on a read-only filesystem.
241 The \fBbind()\fR function may fail if:
248 The specified address is protected, and \fB{PRIV_NET_PRIVADOR}\fR is not
249 asserted in the effective set of the current process.
258 The \fIaddress_len\fR argument is not a valid length for the address family.
267 The socket is already connected.
273 \fB\fBENAMETOOLONG\fR\fR
276 Pathname resolution of a symbolic link produced an intermediate result whose
277 length exceeds \fIPATH_MAX\fR.
286 Insufficient resources were available to complete the call.
295 There were insufficient STREAMS resources for the operation to complete.
301 See \fBattributes\fR(5) for descriptions of the following attributes:
309 ATTRIBUTE TYPE ATTRIBUTE VALUE
311 Interface Stability Standard
319 \fBconnect\fR(3XNET), \fBgetsockname\fR(3XNET), \fBlisten\fR(3XNET),
320 \fBsocket\fR(3XNET), \fBattributes\fR(5), \fBprivileges\fR(5),