1 .\" $NetBSD: bind.2,v 1.8 1995/10/12 15:40:46 jtc Exp $
3 .\" Copyright (c) 1983, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by the University of
17 .\" California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)bind.2 8.1 (Berkeley) 6/4/93
41 .Nd bind a name to a socket
43 .Fd #include <sys/types.h>
44 .Fd #include <sys/socket.h>
46 .Fn bind "int s" "const struct sockaddr *name" "socklen_t namelen"
49 assigns a name to an unnamed socket.
50 When a socket is created
53 it exists in a name space (address family)
54 but has no name assigned.
58 be assigned to the socket.
60 Binding a name in the UNIX domain creates a socket in the file
61 system that must be deleted by the caller when it is no longer
65 The rules used in name binding vary between communication domains.
66 Consult the manual entries in section 4 for detailed information.
68 If the bind is successful, a 0 value is returned.
69 A return value of -1 indicates an error, which is
70 further specified in the global
79 is not a valid descriptor.
83 .It Bq Er EADDRNOTAVAIL
84 The specified address is not available from the local machine.
86 The specified address is already in use.
88 The socket is already bound to an address.
90 The requested address is protected, and the current user
91 has inadequate permission to access it.
95 parameter is not in a valid part of the user
99 The following errors are specific to binding names in the UNIX domain.
102 A component of the path prefix is not a directory.
103 .It Bq Er ENAMETOOLONG
104 A component of a pathname exceeded
106 characters, or an entire path name exceeded
110 A prefix component of the path name does not exist.
112 Too many symbolic links were encountered in translating the pathname.
114 An I/O error occurred while making the directory entry or allocating the inode.
116 The name would reside on a read-only file system.
118 An empty pathname was specified.
128 function call appeared in