bbiinndd() -- Sockets Function (libsocket)

Bind a name to a socket
#iinncclluuddee <ssyyss/ttyyppeess.hh>
#iinncclluuddee <ssyyss/ssoocckkeett.hh>
iinntt bbiinndd (_s_o_c_k_e_t, _n_a_m_e, _n_a_m_e_l_e_n)
iinntt _s_o_c_k_e_t, _n_a_m_e_l_e_n; ssttrruucctt ssoocckkaaddddrr *_n_a_m_e;

The  function bbiinndd()  binds a  name  to an  unnamed socket.   When function
ssoocckkeett() creates  a socket, that socket  exists in a name  space but has no
name.  bbiinndd() creates  a file, assigns it a name,  and binds that file to a
socket.  Thereafter, the socket can be accessed by writing to the file.

_s_o_c_k_e_t is  a file  descriptor that identifies  the socket in  question.  It
must have been returned by a call to ssoocckkeett(). _n_a_m_e points to the full path
name of the file to which  _s_o_c_k_e_t is to be bound.  The calling process must
unlink _n_a_m_e when it no longer  needs it.  _n_a_m_e_l_e_n gives the number of bytes
in the path name name to  which _n_a_m_e points.  Under COHERENT, no element of
_n_a_m_e can exceed 14 characters (not including separating `/' characters).

If all  goes well,  bbiinndd() returns zero.   If something goes  wrong, bbiinndd()
returns -1 and sets eerrrrnnoo to an appropriate value.  The following lists the
errors that can occur, by the value to which bbiinndd() sets eerrrrnnoo:

EEBBAADDFF
     _s_o_c_k_e_t is somehow not a valid descriptor.

EENNOOTTSSOOCCKK
     _s_o_c_k_e_t is not a socket.

EEAADDDDRRNNOOTTAAVVAAIILL
     _n_a_m_e is not available from the local machine.

EEAADDDDRRIINNUUSSEE
     _n_a_m_e is already bound to another socket.

EEIINNVVAALL
     _s_o_c_k_e_t is already bound to a name.

EEAACCCCEESS
     The  memory to  which  _n_a_m_e points  is  protected and  the user  lacks
     permission to access it.

EEFFAAUULLTT
     _n_a_m_e points to an illegal address.

EENNOOTTDDIIRR
     The path name  to which _n_a_m_e points contains an  element that is not a
     directory.

EEIINNVVAALL
     The path name to which _n_a_m_e points contains a character with the high-
     order bit set.

EENNOOEENNTT
     A prefix component of the path name does not exist.

EEIIOO  An I/O  error occurred while creating the directory  entry for _n_a_m_e or
     allocating its inode.

EERROOFFSS
     _n_a_m_e would reside on a read-only file system.

EEIISSDDIIRR
     _n_a_m_e points to an empty path name.

_E_x_a_m_p_l_e
For an example of this function, see the Lexicon entry for lliibbssoocckkeett.

_S_e_e _A_l_s_o
ccoonnnneecctt(), ggeettssoocckknnaammee(), lliibbssoocckkeett, lliisstteenn(), ssoocckkeett()
