Commit | Line | Data |
---|---|---|
1418f8f7 KM |
1 | .\" Copyright (c) 1983 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
d84f45ef | 5 | .\" @(#)bind.2 6.3 (Berkeley) %G% |
1418f8f7 | 6 | .\" |
27b162cf | 7 | .TH BIND 2 "" |
1418f8f7 KM |
8 | .UC 5 |
9 | .SH NAME | |
10 | bind \- bind a name to a socket | |
11 | .SH SYNOPSIS | |
12 | .nf | |
13 | .ft B | |
14 | #include <sys/types.h> | |
15 | #include <sys/socket.h> | |
16 | .PP | |
17 | .ft B | |
18 | bind(s, name, namelen) | |
19 | int s; | |
20 | struct sockaddr *name; | |
21 | int namelen; | |
22 | .fi | |
23 | .SH DESCRIPTION | |
24 | .I Bind | |
25 | assigns a name to an unnamed socket. | |
26 | When a socket is created | |
27 | with | |
28 | .IR socket (2) | |
29 | it exists in a name space (address family) | |
30 | but has no name assigned. | |
31 | .I Bind | |
32 | requests the | |
33 | .IR name , | |
34 | be assigned to the socket. | |
35 | .SH NOTES | |
36 | Binding a name in the UNIX domain creates a socket in the file | |
d84f45ef | 37 | system that must be deleted by the caller when it is no longer |
1418f8f7 KM |
38 | needed (using |
39 | .IR unlink (2)). | |
40 | The file created | |
41 | is a side-effect of the current implementation, | |
42 | and will not be created in future versions | |
43 | of the UNIX ipc domain. | |
44 | .PP | |
45 | The rules used in name binding vary between communication domains. | |
46 | Consult the manual entries in section 4 for detailed information. | |
47 | .SH "RETURN VALUE | |
48 | If the bind is successful, a 0 value is returned. | |
49 | A return value of \-1 indicates an error, which is | |
50 | further specified in the global \fIerrno\fP. | |
51 | .SH ERRORS | |
52 | The \fIbind\fP call will fail if: | |
53 | .TP 20 | |
54 | [EBADF] | |
55 | \fIS\fP is not a valid descriptor. | |
56 | .TP 20 | |
57 | [ENOTSOCK] | |
58 | \fIS\fP is not a socket. | |
59 | .TP 20 | |
60 | [EADDRNOTAVAIL] | |
61 | The specified address is not available from the local machine. | |
62 | .TP 20 | |
63 | [EADDRINUSE] | |
64 | The specified address is already in use. | |
65 | .TP 20 | |
66 | [EINVAL] | |
67 | The socket is already bound to an address. | |
68 | .TP 20 | |
69 | [EACCESS] | |
70 | The requested address is protected, and the current user | |
71 | has inadequate permission to access it. | |
72 | .TP 20 | |
73 | [EFAULT] | |
74 | The \fIname\fP parameter is not in a valid part of the user | |
75 | address space. | |
b5984ffe KM |
76 | .PP |
77 | The following errors are specific to binding names in the UNIX domain. | |
78 | These errors may not apply in future versions of the UNIX ipc domain. | |
79 | .TP 15 | |
80 | [ENOTDIR] | |
81 | A component of the path prefix is not a directory. | |
82 | .TP 15 | |
83 | [EINVAL] | |
84 | The pathname contains a character with the high-order bit set. | |
85 | .TP 15 | |
86 | [ENAMETOOLONG] | |
87 | A component of a pathname exceeded 255 characters, | |
88 | or an entire path name exceeded 1023 characters. | |
89 | .TP 15 | |
90 | [ENOENT] | |
91 | A prefix component of the path name does not exist. | |
92 | .TP 15 | |
93 | [ELOOP] | |
94 | Too many symbolic links were encountered in translating the pathname. | |
95 | .TP 15 | |
96 | [EIO] | |
97 | An I/O error occurred while making the directory entry or allocating the inode. | |
98 | .TP 15 | |
99 | [EROFS] | |
100 | The name would reside on a read-only file system. | |
101 | .TP 15 | |
102 | [EISDIR] | |
103 | A null pathname was specified. | |
1418f8f7 KM |
104 | .SH SEE ALSO |
105 | connect(2), listen(2), socket(2), getsockname(2) |