BIND(2) COMMAND REFERENCE BIND(2) NAME bind - bind a name to a socket SYNOPSIS #include <sys/types.h> #include <sys/socket.h> bind(s, name, namelen) int s; struct sockaddr *name; int namelen; DESCRIPTION Bind assigns a name to an unnamed socket. When a socket is created with socket(2) it exists in a name space (address family) but has no name assigned. Bind requests the name, be assigned to the socket. Binding a name creates a socket in the file system which must be deleted by the caller when it is no longer needed (using unlink(2)). The file created is a side-effect of the current implementation, and will not be created in future versions of the UTek ipc domain. The rules used in name binding vary between communication domains. Consult the manual entries in section 4 for detailed information. Name for an internet domain socket has three components, an address family type, a port number, and an internet address. See /usr/include/netinet/in.h for the appropriate data structures. A domain socket has two components, an address family and a pathname to a "file" that serves as a communications rendezvous point. See /usr/include/sys/un.h for the appropirate data structures. Suppose you wish to set up a communications channel between two independent processes that models a client-server relationship. The server would do a socket(2) call (using type SOCK_STREAM) followed by a bind, a listen(2), and an accept(2). The client would do a socket(2) call, followed by a connect(2) DIAGNOSTICS The bind call will fail if: [EBADF] S is not a valid descriptor. [ENOTSOCK] S is not a socket. [EADDRNOTAVAIL] The specified address (in the internet domain) Printed 5/12/88 1
BIND(2) COMMAND REFERENCE BIND(2) or name (in the UTek domain) is not available from the local machine. [EADDRINUSE] The specified address (in the internet domain) or name (in the UTek domain) is already in use. [EMSGSIZE] The specified address size (in the internet domain) or name (in the UTek domain) is too big for the protocol. The pathname of a UTek domain socket is limited to 108 bytes. [EINVAL] The socket is already bound to an address (in the internet domain) or name (in the UTek domain). [EACCESS] The requested address (in the internet domain) or address (in the UTek domain) is protected, and the current user has inadequate permission to access it. Internet address port numbers less than 1024 are privileged, meaning that you can't bind to them unless you are root (or, as in the case with rcp(1n), owned by root with the setuid bit on). [EFAULT] The name parameter is not in a valid part of the user address space. RETURN VALUE [0] Bind was successful. [-1] Bind was unsuccessful. The error is further specified in the global errno. SEE ALSO connect(2), listen(2), socket(2), and getsockname(2). Printed 5/12/88 2
%%index%% na:240,82; sy:322,1224; de:1546,1860; di:3406,372;4090,1251; rv:5341,342; se:5683,223; %%index%%000000000120