Commit | Line | Data |
---|---|---|
da268306 KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
1418f8f7 | 3 | .\" |
af359dea C |
4 | .\" Redistribution and use in source and binary forms, with or without |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
da268306 | 19 | .\" |
af359dea C |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
1418f8f7 | 31 | .\" |
af359dea C |
32 | .\" @(#)bind.2 6.9 (Berkeley) 3/10/91 |
33 | .\" | |
34 | .Dd March 10, 1991 | |
931b8415 CL |
35 | .Dt BIND 2 |
36 | .Os BSD 4.2 | |
37 | .Sh NAME | |
38 | .Nm bind | |
39 | .Nd bind a name to a socket | |
40 | .Sh SYNOPSIS | |
41 | .Fd #include <sys/types.h> | |
42 | .Fd #include <sys/socket.h> | |
43 | .Ft int | |
44 | .Fn bind "int s" "struct sockaddr *name" "int namelen" | |
45 | .Sh DESCRIPTION | |
46 | .Fn Bind | |
1418f8f7 KM |
47 | assigns a name to an unnamed socket. |
48 | When a socket is created | |
49 | with | |
931b8415 | 50 | .Xr socket 2 |
1418f8f7 KM |
51 | it exists in a name space (address family) |
52 | but has no name assigned. | |
931b8415 | 53 | .Fn Bind |
efd03614 | 54 | requests that |
931b8415 | 55 | .Fa name |
1418f8f7 | 56 | be assigned to the socket. |
931b8415 | 57 | .Sh NOTES |
1418f8f7 | 58 | Binding a name in the UNIX domain creates a socket in the file |
d84f45ef | 59 | system that must be deleted by the caller when it is no longer |
1418f8f7 | 60 | needed (using |
931b8415 CL |
61 | .Xr unlink 2 ) . |
62 | .Pp | |
1418f8f7 KM |
63 | The rules used in name binding vary between communication domains. |
64 | Consult the manual entries in section 4 for detailed information. | |
931b8415 | 65 | .Sh RETURN VALUES |
1418f8f7 | 66 | If the bind is successful, a 0 value is returned. |
931b8415 CL |
67 | A return value of -1 indicates an error, which is |
68 | further specified in the global | |
69 | .Va errno . | |
70 | .Sh ERRORS | |
71 | The | |
72 | .Fn bind | |
73 | call will fail if: | |
74 | .Bl -tag -width EADDRNOTAVA | |
75 | .It Bq Er EBADF | |
76 | .Fa S | |
77 | is not a valid descriptor. | |
78 | .It Bq Er ENOTSOCK | |
79 | .Fa S | |
80 | is not a socket. | |
81 | .It Bq Er EADDRNOTAVAIL | |
1418f8f7 | 82 | The specified address is not available from the local machine. |
931b8415 | 83 | .It Bq Er EADDRINUSE |
1418f8f7 | 84 | The specified address is already in use. |
931b8415 | 85 | .It Bq Er EINVAL |
1418f8f7 | 86 | The socket is already bound to an address. |
931b8415 | 87 | .It Bq Er EACCES |
1418f8f7 KM |
88 | The requested address is protected, and the current user |
89 | has inadequate permission to access it. | |
931b8415 CL |
90 | .It Bq Er EFAULT |
91 | The | |
92 | .Fa name | |
93 | parameter is not in a valid part of the user | |
1418f8f7 | 94 | address space. |
931b8415 CL |
95 | .El |
96 | .Pp | |
b5984ffe | 97 | The following errors are specific to binding names in the UNIX domain. |
931b8415 CL |
98 | .Bl -tag -width EADDRNOTAVA |
99 | .It Bq Er ENOTDIR | |
b5984ffe | 100 | A component of the path prefix is not a directory. |
931b8415 | 101 | .It Bq Er EINVAL |
b5984ffe | 102 | The pathname contains a character with the high-order bit set. |
931b8415 | 103 | .It Bq Er ENAMETOOLONG |
b5984ffe KM |
104 | A component of a pathname exceeded 255 characters, |
105 | or an entire path name exceeded 1023 characters. | |
931b8415 | 106 | .It Bq Er ENOENT |
b5984ffe | 107 | A prefix component of the path name does not exist. |
931b8415 | 108 | .It Bq Er ELOOP |
b5984ffe | 109 | Too many symbolic links were encountered in translating the pathname. |
931b8415 | 110 | .It Bq Er EIO |
b5984ffe | 111 | An I/O error occurred while making the directory entry or allocating the inode. |
931b8415 | 112 | .It Bq Er EROFS |
b5984ffe | 113 | The name would reside on a read-only file system. |
931b8415 CL |
114 | .It Bq Er EISDIR |
115 | An empty pathname was specified. | |
116 | .El | |
117 | .Sh SEE ALSO | |
118 | .Xr connect 2 , | |
119 | .Xr listen 2 , | |
120 | .Xr socket 2 , | |
121 | .Xr getsockname 2 | |
122 | .Sh HISTORY | |
123 | The | |
124 | .Nm | |
125 | function call appeared in | |
126 | .Bx 4.2 . |