MAN page from Mandrake Other man-pages-gz-1.21-2.noarch.rpm
BIND
Section: Linux Programmer's Manual (2)
Updated: 23 July 1993
Index NAME
bind - bind a name to a socket
SYNOPSIS
#include <sys/types.h>#include <sys/socket.h>int bind(int sockfd, struct sockaddr *my_addr, int addrlen);
DESCRIPTION
bindgives the socket,
sockfd,the local address
my_addr.
my_addris
addrlenbytes long. Traditionally, this is called "assigning a name to a socket"(when a socket is created with
socket(2),it exists in a name space (address family) but has no name assigned.)
NOTES
Binding a name in the UNIX domain creates a socket in the file systemthat must be deleted by the caller when it is no longer needed (using
unlink(2)).
The rules used in name binding vary between communication domains. Consultthe manual entries in section 4 for detailed information.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and
errnois set appropriately.
ERRORS
- EBADF
- sockfdis not a valid descriptor.
- EINVAL
- The socket is already bound to an address. This may change in the future:seelinux/unix/sock.cfor details.
- EACCES
- The address is protected, and the user is not the super-user.
- ENOTSOCK
- Argument is a descriptor for a file, not a socket.
The following errors are specific to UNIX domain (AF_UNIX) sockets:
- EINVAL
- Theaddr_lenwas wrong, or the socket was not in theAF_UNIXfamily.
- EROFS
- The socket inode would reside on a read-only file system.
- EFAULT
- my_addrpoints outside your accessible address space.
- ENAMETOOLONG
- my_addris too long.
- ENOENT
- The file does not exist.
- ENOMEM
- Insufficient kernel memory was available.
- ENOTDIR
- A component of the path prefix is not a directory.
- EACCES
- Search permission is denied on a component of the path prefix.
- ELOOP
- Too many symbolic links were encountered in resolvingmy_addr.
CONFORMING TO
SVr4, 4.4BSD (the
bindfunction first appeared in BSD 4.2). SVr4 documents additionalEADDRNOTAVAIL, EADDRINUSE, ENOSR general error conditions, andadditional EIO, EISDIR and EROFS Unix-domain error conditions.
SEE ALSO
accept(2),
connect(2),
listen(2),
socket(2),
getsockname(2)
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- NOTES
- RETURN VALUE
- ERRORS
- CONFORMING TO
- SEE ALSO
This document was created byman2html,using the manual pages.