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 | .\" | |
5 | .\" @(#)bind.2 5.1 (Berkeley) %G% | |
6 | .\" | |
7 | .TH BIND 2 "27 July 1983" | |
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 | |
37 | system which must be deleted by the caller when it is no longer | |
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. | |
76 | .SH SEE ALSO | |
77 | connect(2), listen(2), socket(2), getsockname(2) |