Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
bind(2)
Edit
PageHistory
Diff
Info
LikePages
BIND !!!BIND ---- !!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''__, socklen_t__ ''addrlen''__);__ !!DESCRIPTION __bind__ gives the socket ''sockfd'' the local address ''my_addr''. ''my_addr'' is ''addrlen'' bytes 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. It is normally necessary to assign a local address using __bind__ before a __SOCK_STREAM__ socket may receive connections (see accept(2)). !!NOTES The rules used in name binding vary between address families. Consult the manual entries in Section 7 for detailed information. For __AF_INET__ see ip(7), for __AF_UNIX__ see unix(7), for __AF_APPLETALK__ see ddp(7), for __AF_PACKET__ see packet(7), for __AF_X25__ see x25(7) and for __AF_NETLINK__ see netlink(7). !!RETURN VALUE On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately. !!ERRORS ;[EBADF]: ''sockfd'' is not a valid descriptor. ;[EINVAL]: The socket is already bound to an address. This may change in the future: see ''linux/unix/sock.c'' for 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]: The ''addrlen'' is wrong, or the socket was not in the __AF_UNIX__ family. ;[EROFS]: The socket inode would reside on a read-only file system. ;[EFAULT]: ''my_addr'' points outside the user's accessible address space. ;[ENAMETOOLONG]: ''my_addr'' is 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 resolving ''my_addr''. !!BUGS The transparent proxy options are not described. !!CONFORMING TO SVr4, 4.4BSD (the __bind__ function first appeared in BSD 4.2). SVr4 documents additional [EADDRNOTAVAIL], [EADDRINUSE], and [ENOSR] general error conditions, and additional [EIO] and [EISDIR] Unix-domain error conditions. !!NOTE The third argument of __bind__ is in reality an int (and this is what BSD 4.* and libc4 and libc5 have). Some POSIX confusion resulted in the present socklen_t. The draft standard has not been adopted yet, but glibc2 already follows it and also has socklen_t. See also accept(2). !!SEE ALSO accept(2), connect(2), listen(2), socket(2), getsockname(2), ip(7), socket(7), CategorySocketSysCalls
30 pages link to
bind(2)
:
AddressFamily
udp(7)
EAFNOSUPPORT
ddp(7)
ndc(8)
socketcall(2)
tcp(7)
Man2b
services(5)
root
freeaddrinfo(3)
gai_strerror(3)
getaddrinfo(3)
netlink(7)
unix(7)
raw(7)
socket(7)
tcptraceroute(8)
connect(2)
getpeername(2)
socket(2)
getsockname(2)
packet(7)
accept(2)
EADDRNOTAVAIL
listen(2)
NetworkProgramming
NetworkProgrammingOld
ENOTDIR
ip(7)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.