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