1BIND(2)                       System Calls Manual                      BIND(2)
2
3
4

NAME

6       bind - bind a name to a socket
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/socket.h>
11
12       bind(s, name, namelen)
13       int s;
14       struct sockaddr *name;
15       int namelen;
16

DESCRIPTION

18       Bind  assigns  a  name  to an unnamed socket.  When a socket is created
19       with socket(2) it exists in a name space (address family)  but  has  no
20       name assigned.  Bind requests that name be assigned to the socket.
21

NOTES

23       Binding  a  name in the UNIX domain creates a socket in the file system
24       that must be deleted by the caller when it is no longer  needed  (using
25       unlink(2)).
26
27       The  rules  used  in  name  binding vary between communication domains.
28       Consult the manual entries in section 4 for detailed information.
29

RETURN VALUE

31       If the bind is successful, a 0 value is returned.  A return value of -1
32       indicates an error, which is further specified in the global errno.
33

ERRORS

35       The bind call will fail if:
36
37       [EBADF]             S is not a valid descriptor.
38
39       [ENOTSOCK]          S is not a socket.
40
41       [EADDRNOTAVAIL]     The  specified  address  is  not available from the
42                           local machine.
43
44       [EADDRINUSE]        The specified address is already in use.
45
46       [EINVAL]            The socket is already bound to an address.
47
48       [EACCES]            The requested address is protected, and the current
49                           user has inadequate permission to access it.
50
51       [EFAULT]            The  name  parameter  is not in a valid part of the
52                           user address space.
53
54       The following errors are specific to binding names in the UNIX domain.
55
56       [ENOTDIR]      A component of the path prefix is not a directory.
57
58       [EINVAL]       The pathname contains a character  with  the  high-order
59                      bit set.
60
61       [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an
62                      entire path name exceeded 1023 characters.
63
64       [ENOENT]       A prefix component of the path name does not exist.
65
66       [ELOOP]        Too many symbolic links were encountered in  translating
67                      the pathname.
68
69       [EIO]          An  I/O  error occurred while making the directory entry
70                      or allocating the inode.
71
72       [EROFS]        The name would reside on a read-only file system.
73
74       [EISDIR]       A null pathname was specified.
75

SEE ALSO

77       connect(2), listen(2), socket(2), getsockname(2)
78
79
80
814.2 Berkeley Distribution        May 22, 1986                          BIND(2)
Impressum