|
|
1.1 root 1: .\" Copyright (c) 1983 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)bind.2 6.8 (Berkeley) 6/23/90
19: .\"
20: .TH BIND 2 "June 23, 1990"
21: .UC 5
22: .SH NAME
23: bind \- bind a name to a socket
24: .SH SYNOPSIS
25: .nf
26: .ft B
27: #include <sys/types.h>
28: #include <sys/socket.h>
29: .PP
30: .ft B
31: bind(s, name, namelen)
32: int s;
33: struct sockaddr *name;
34: int namelen;
35: .fi
36: .SH DESCRIPTION
37: .I Bind
38: assigns a name to an unnamed socket.
39: When a socket is created
40: with
41: .IR socket (2)
42: it exists in a name space (address family)
43: but has no name assigned.
44: .I Bind
45: requests that
46: .IR name
47: be assigned to the socket.
48: .SH NOTES
49: Binding a name in the UNIX domain creates a socket in the file
50: system that must be deleted by the caller when it is no longer
51: needed (using
52: .IR unlink (2)).
53: .PP
54: The rules used in name binding vary between communication domains.
55: Consult the manual entries in section 4 for detailed information.
56: .SH "RETURN VALUE
57: If the bind is successful, a 0 value is returned.
58: A return value of \-1 indicates an error, which is
59: further specified in the global \fIerrno\fP.
60: .SH ERRORS
61: The \fIbind\fP call will fail if:
62: .TP 20
63: [EBADF]
64: \fIS\fP is not a valid descriptor.
65: .TP 20
66: [ENOTSOCK]
67: \fIS\fP is not a socket.
68: .TP 20
69: [EADDRNOTAVAIL]
70: The specified address is not available from the local machine.
71: .TP 20
72: [EADDRINUSE]
73: The specified address is already in use.
74: .TP 20
75: [EINVAL]
76: The socket is already bound to an address.
77: .TP 20
78: [EACCES]
79: The requested address is protected, and the current user
80: has inadequate permission to access it.
81: .TP 20
82: [EFAULT]
83: The \fIname\fP parameter is not in a valid part of the user
84: address space.
85: .PP
86: The following errors are specific to binding names in the UNIX domain.
87: .TP 15
88: [ENOTDIR]
89: A component of the path prefix is not a directory.
90: .TP 15
91: [EINVAL]
92: The pathname contains a character with the high-order bit set.
93: .TP 15
94: [ENAMETOOLONG]
95: A component of a pathname exceeded 255 characters,
96: or an entire path name exceeded 1023 characters.
97: .TP 15
98: [ENOENT]
99: A prefix component of the path name does not exist.
100: .TP 15
101: [ELOOP]
102: Too many symbolic links were encountered in translating the pathname.
103: .TP 15
104: [EIO]
105: An I/O error occurred while making the directory entry or allocating the inode.
106: .TP 15
107: [EROFS]
108: The name would reside on a read-only file system.
109: .TP 15
110: [EISDIR]
111: A null pathname was specified.
112: .SH SEE ALSO
113: connect(2), listen(2), socket(2), getsockname(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.