1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
26 HREF="net-common-tcpip-manpages-accept.html"><LINK
29 HREF="net-common-tcpip-manpages-connect.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-accept.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-connect.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-BIND">bind</H1
94 >BIND(2) System Calls Manual BIND(2)
97 bind - bind a name to a socket
100 #include <sys/types.h>
101 #include <sys/socket.h>
104 bind(int s, const struct sockaddr *name, socklen_t namelen);
107 bind() assigns a name to an unnamed socket. When a socket is created
108 with socket(2) it exists in a name space (address family) but has no name
109 assigned. bind() requests that name be assigned to the socket.
112 Binding a name in the UNIX domain creates a socket in the file system
113 that must be deleted by the caller when it is no longer needed (using
116 The rules used in name binding vary between communication domains. Con-
117 sult the manual entries in section 4 for detailed information.
120 If the bind is successful, a 0 value is returned. A return value of -1
121 indicates an error, which is further specified in the global errno.
124 The bind() call will fail if:
126 [EBADF] S is not a valid descriptor.
128 [ENOTSOCK] S is not a socket.
130 [EADDRNOTAVAIL] The specified address is not available from the local
133 [EADDRINUSE] The specified address is already in use.
135 [EINVAL] The socket is already bound to an address.
137 [EINVAL] The family of the socket and that requested in
138 name->sa_family are not equivalent.
140 [EACCES] The requested address is protected, and the current
141 user has inadequate permission to access it.
143 [EFAULT] The name parameter is not in a valid part of the user
146 The following errors are specific to binding names in the UNIX domain.
148 [ENOTDIR] A component of the path prefix is not a directory.
150 [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} charac-
151 ters, or an entire path name exceeded {PATH_MAX} char-
154 [ENOENT] A prefix component of the path name does not exist.
156 [ELOOP] Too many symbolic links were encountered in translat-
159 [EIO] An I/O error occurred while making the directory entry
160 or allocating the inode.
162 [EROFS] The name would reside on a read-only file system.
164 [EISDIR] An empty pathname was specified.
167 connect(2), getsockname(2), listen(2), socket(2)
170 The bind() function call appeared in 4.2BSD.
172 BSD February 15, 1999 BSD
183 SUMMARY="Footer navigation table"
194 HREF="net-common-tcpip-manpages-accept.html"
212 HREF="net-common-tcpip-manpages-connect.html"
228 HREF="tcpip-library-reference.html"