<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>bind</TITLE
|
>bind</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="TCP/IP Library Reference"
|
TITLE="TCP/IP Library Reference"
|
HREF="tcpip-library-reference.html"><LINK
|
HREF="tcpip-library-reference.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="accept"
|
TITLE="accept"
|
HREF="net-common-tcpip-manpages-accept.html"><LINK
|
HREF="net-common-tcpip-manpages-accept.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="connect"
|
TITLE="connect"
|
HREF="net-common-tcpip-manpages-connect.html"></HEAD
|
HREF="net-common-tcpip-manpages-connect.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="SECT1"
|
CLASS="SECT1"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-accept.html"
|
HREF="net-common-tcpip-manpages-accept.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
>Chapter 38. TCP/IP Library Reference</TD
|
>Chapter 38. TCP/IP Library Reference</TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-connect.html"
|
HREF="net-common-tcpip-manpages-connect.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><H1
|
><H1
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><A
|
><A
|
NAME="NET-COMMON-TCPIP-MANPAGES-BIND">bind</H1
|
NAME="NET-COMMON-TCPIP-MANPAGES-BIND">bind</H1
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="SCREEN"
|
CLASS="SCREEN"
|
>BIND(2) System Calls Manual BIND(2)
|
>BIND(2) System Calls Manual BIND(2)
|
|
|
NAME
|
NAME
|
bind - bind a name to a socket
|
bind - bind a name to a socket
|
|
|
SYNOPSIS
|
SYNOPSIS
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#include <sys/socket.h>
|
#include <sys/socket.h>
|
|
|
int
|
int
|
bind(int s, const struct sockaddr *name, socklen_t namelen);
|
bind(int s, const struct sockaddr *name, socklen_t namelen);
|
|
|
DESCRIPTION
|
DESCRIPTION
|
bind() assigns a name to an unnamed socket. When a socket is created
|
bind() assigns a name to an unnamed socket. When a socket is created
|
with socket(2) it exists in a name space (address family) but has no name
|
with socket(2) it exists in a name space (address family) but has no name
|
assigned. bind() requests that name be assigned to the socket.
|
assigned. bind() requests that name be assigned to the socket.
|
|
|
NOTES
|
NOTES
|
Binding a name in the UNIX domain creates a socket in the file system
|
Binding a name in the UNIX domain creates a socket in the file system
|
that must be deleted by the caller when it is no longer needed (using
|
that must be deleted by the caller when it is no longer needed (using
|
unlink(2)).
|
unlink(2)).
|
|
|
The rules used in name binding vary between communication domains. Con-
|
The rules used in name binding vary between communication domains. Con-
|
sult the manual entries in section 4 for detailed information.
|
sult the manual entries in section 4 for detailed information.
|
|
|
RETURN VALUES
|
RETURN VALUES
|
If the bind is successful, a 0 value is returned. A return value of -1
|
If the bind is successful, a 0 value is returned. A return value of -1
|
indicates an error, which is further specified in the global errno.
|
indicates an error, which is further specified in the global errno.
|
|
|
ERRORS
|
ERRORS
|
The bind() call will fail if:
|
The bind() call will fail if:
|
|
|
[EBADF] S is not a valid descriptor.
|
[EBADF] S is not a valid descriptor.
|
|
|
[ENOTSOCK] S is not a socket.
|
[ENOTSOCK] S is not a socket.
|
|
|
[EADDRNOTAVAIL] The specified address is not available from the local
|
[EADDRNOTAVAIL] The specified address is not available from the local
|
machine.
|
machine.
|
|
|
[EADDRINUSE] The specified address is already in use.
|
[EADDRINUSE] The specified address is already in use.
|
|
|
[EINVAL] The socket is already bound to an address.
|
[EINVAL] The socket is already bound to an address.
|
|
|
[EINVAL] The family of the socket and that requested in
|
[EINVAL] The family of the socket and that requested in
|
name->sa_family are not equivalent.
|
name->sa_family are not equivalent.
|
|
|
[EACCES] The requested address is protected, and the current
|
[EACCES] The requested address is protected, and the current
|
user has inadequate permission to access it.
|
user has inadequate permission to access it.
|
|
|
[EFAULT] The name parameter is not in a valid part of the user
|
[EFAULT] The name parameter is not in a valid part of the user
|
address space.
|
address space.
|
|
|
The following errors are specific to binding names in the UNIX domain.
|
The following errors are specific to binding names in the UNIX domain.
|
|
|
[ENOTDIR] A component of the path prefix is not a directory.
|
[ENOTDIR] A component of the path prefix is not a directory.
|
|
|
[ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} charac-
|
[ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} charac-
|
ters, or an entire path name exceeded {PATH_MAX} char-
|
ters, or an entire path name exceeded {PATH_MAX} char-
|
acters.
|
acters.
|
|
|
[ENOENT] A prefix component of the path name does not exist.
|
[ENOENT] A prefix component of the path name does not exist.
|
|
|
[ELOOP] Too many symbolic links were encountered in translat-
|
[ELOOP] Too many symbolic links were encountered in translat-
|
ing the pathname.
|
ing the pathname.
|
|
|
[EIO] An I/O error occurred while making the directory entry
|
[EIO] An I/O error occurred while making the directory entry
|
or allocating the inode.
|
or allocating the inode.
|
|
|
[EROFS] The name would reside on a read-only file system.
|
[EROFS] The name would reside on a read-only file system.
|
|
|
[EISDIR] An empty pathname was specified.
|
[EISDIR] An empty pathname was specified.
|
|
|
SEE ALSO
|
SEE ALSO
|
connect(2), getsockname(2), listen(2), socket(2)
|
connect(2), getsockname(2), listen(2), socket(2)
|
|
|
HISTORY
|
HISTORY
|
The bind() function call appeared in 4.2BSD.
|
The bind() function call appeared in 4.2BSD.
|
|
|
BSD February 15, 1999 BSD
|
BSD February 15, 1999 BSD
|
</PRE
|
</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-accept.html"
|
HREF="net-common-tcpip-manpages-accept.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="net-common-tcpip-manpages-connect.html"
|
HREF="net-common-tcpip-manpages-connect.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>accept</TD
|
>accept</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="tcpip-library-reference.html"
|
HREF="tcpip-library-reference.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>connect</TD
|
>connect</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|