Penguin
Annotated edit history of bind(2) version 4, including all changes. View license author blame.
Rev Author # Line
1 perry 1 BIND
2 !!!BIND
3 ----
4 !!NAME
5
6 bind - bind a name to a socket
7 !!SYNOPSIS
8
9
3 PerryLorier 10 __#include <sys/types.h>__
11 __#include <sys/socket.h>__
1 perry 12
3 PerryLorier 13 __int bind(int__ ''sockfd''__, struct sockaddr *__''my_addr''__, socklen_t__ ''addrlen''__);__
1 perry 14
15 !!DESCRIPTION
3 PerryLorier 16 __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
17 exists in a name space (address family) but has no name assigned.
1 perry 18
3 PerryLorier 19 It is normally necessary to assign a local address using __bind__ before a __SOCK_STREAM__ socket may receive connections (see accept(2)).
1 perry 20
21 !!NOTES
3 PerryLorier 22 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).
1 perry 23
24 !!RETURN VALUE
3 PerryLorier 25 On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately.
1 perry 26 !!ERRORS
27
3 PerryLorier 28 ;[EBADF]: ''sockfd'' is not a valid descriptor.
29 ;[EINVAL]: The socket is already bound to an address. This may change in the future: see ''linux/unix/sock.c'' for details.
30 ;[EACCES]: The address is protected, and the user is not the super-user.
31 ;[ENOTSOCK]: Argument is a descriptor for a file, not a socket.
1 perry 32
3 PerryLorier 33 The following errors are specific to UNIX domain (__AF_UNIX__) sockets:
1 perry 34
3 PerryLorier 35 ;[EINVAL]: The ''addrlen'' is wrong, or the socket was not in the __AF_UNIX__ family.
36 ;[EROFS]: The socket inode would reside on a read-only file system.
37 ;[EFAULT]: ''my_addr'' points outside the user's accessible address space.
38 ;[ENAMETOOLONG]: ''my_addr'' is too long.
39 ;[ENOENT]: The file does not exist.
40 ;[ENOMEM]: Insufficient kernel memory was available.
41 ;[ENOTDIR]: A component of the path prefix is not a directory.
42 ;[EACCES]: Search permission is denied on a component of the path prefix.
43 ;[ELOOP]: Too many symbolic links were encountered in resolving ''my_addr''.
1 perry 44
45 !!BUGS
3 PerryLorier 46 The transparent proxy options are not described.
1 perry 47
48 !!CONFORMING TO
3 PerryLorier 49 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]
50 Unix-domain error conditions.
1 perry 51
52 !!NOTE
3 PerryLorier 53 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).
1 perry 54
55 !!SEE ALSO
4 PerryLorier 56 accept(2), connect(2), listen(2), socket(2), getsockname(2), ip(7), socket(7), CategorySocketSysCalls
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 9 times)