


UNIX(4F)                PROTOCOL FAMILIES                UNIX(4F)



NAME
     unix - UNIX domain protocol family

DESCRIPTION
     The  Unix  Domain  protocol  family  provides  support   for
     socket-based  communication between processes running on the
     local host.  While both SOCK_STREAM and SOCK_DGRAM types are
     supported,  the  SOCK_STREAM type often provides faster per-
     formance.  Pipes, for instance, are  built  on  Unix  Domain
     SOCK_STREAM sockets.

     Unix Domain SOCK_DGRAM sockets (also called  datagram  sock-
     ets)  exist primarily for reasons of orthogonality under the
     BSD socket model.  However, the overhead of reading or writ-
     ing  data  is higher for the (connectionless) datagram sock-
     ets.

     Unix Domain addresses are pathnames.  In  other  words,  two
     independent processes can communicate by specifying the same
     pathname as  their  communications  rendezvous  point.   The
     bind(2) operation creates a special entry in the file system
     of type socket.  If  that  pathname  already  exists  (as  a
     socket  from  a  previous bind() operation, or as some other
     file system type), bind() will fail.

     Sockets in the Unix domain protocol family  use   the   fol-
     lowing addressing structure:

          struct sockaddr_un {
               short     sun_family;
               u_short   sun_path[108];
          };

     To create or reference a Unix Domain socket, the  sun_family
     field should be set to AF_UNIX and the sun_path array should
     contain the path name of a rendezvous point.

     Although Unix Domain sockets are faster than Internet Domain
     sockets  for  communication  between  local  processes,  the
     advantage of the  additional  flexibility  afforded  by  the
     latter may outweigh performance issues.  Where inter-process
     communication  thoughput  is  critical,  a   shared   memory
     approach may be preferred.

     Since there are no protocol families  associated  with  Unix
     Domain sockets, the protocol argument to socket(2) should be
     zero.

     When setting up a Unix Domain socket, the _l_e_n_g_t_h argument to
     the   bind()   call  is  the  amount  of  space  within  the
     sockaddr_un structure, not including the pathname delimiter.
     One way to specify the length is:



Sun Release 4.1   Last change: 20 October 1988                  1






UNIX(4F)                PROTOCOL FAMILIES                UNIX(4F)



          sizeof(_a_d_d_r._s_u_n__f_a_m_i_l_y) + strlen(_p_a_t_h) where _a_d_d_r is  a
          structure of type sockaddr_un, and _p_a_t_h is a pointer to
          the pathname.

     The limit of 108 characters is an artifact of the  implemen-
     tation.

     Since closing a Unix Domain socket does not  make  the  file
     system entry go away, an application should remove the entry
     using unlink(2V), when finished.

SEE ALSO
     bind(2), socket(2), unlink(2V)

     _N_e_t_w_o_r_k _P_r_o_g_r_a_m_m_i_n_g








































Sun Release 4.1   Last change: 20 October 1988                  2



