Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ bind(2) — UTek W2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

connect(2)

listen(2)

socket(2)

getsockname(2)



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 in the Unix domain 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 Unix 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.




Printed 10/17/86                                                1





BIND(2)                 COMMAND REFERENCE                 BIND(2)



     [EADDRNOTAVAIL]
         The specified address (in the internet domain) or name
         (in the Unix domain) is not available from the local
         machine.

     [EADDRINUSE]
         The specified address (in the internet domain) or name
         (in the Unix domain) is already in use.

     [EMSGSIZE]
         The specified address size (in the internet domain) or
         name (in the Unix domain) is too big for the protocol.
         The pathname of a Unix domain socket is limited to 108
         bytes.

     [EINVAL]
         The socket is already bound to an address (in the
         internet domain) or name (in the Unix domain).

     [EACCESS]
         The requested address (in the internet domain) or
         address (in the Unix 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.

     [EDFSREF]
         Name for a Unix domain socket references a file on a
         remote system (which is not allowed).  If you need that
         capability, use an internet domain socket.

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), getsockname(2).









Printed 10/17/86                                                2





































































%%index%%
na:72,66;
sy:138,796;
de:934,1791;
di:2725,237;3106,1399;
rv:4505,273;
se:4778,180;
%%index%%000000000117

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026