


socket(3)                                               socket(3)


NNAAMMEE
       socket - create an endpoint for communication

SSYYNNOOPPSSIISS
       ##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>

       iinntt ssoocckkeett((iinntt aaff,, iinntt ttyyppee,, iinntt pprroottooccooll));;

DDEESSCCRRIIPPTTIIOONN
       _s_o_c_k_e_t creates an endpoint for communication and returns a
       descriptor.  The socket descriptor returned is used in all
       subsequent socket-related library calls.

       The _a_f parameter specifies an address family to be used to
       interpret addresses in later operations that  specify  the
       socket.  These address families are defined in the include
       file <ssyyss//ssoocckkeett..hh> The only  currently-supported  address
       family is

              AF_UNIX (path names on a local host)

       The  _t_y_p_e specifies the semantics of communication for the
       socket.  Currently defined types are:

              SOCK_STREAM
              SOCK_DGRAM

       A SOCK_STREAM type provides sequenced, reliable,  two-way-
       connection-based  byte  streams.  A SOCK_DGRAM socket sup-
       ports datagrams (connectionless, unreliable messages of  a
       fixed, typically small, maximum length).

       _p_r_o_t_o_c_o_l  specifies  a particular protocol to be used with
       the socket.  Normally, only a single  protocol  exists  to
       support  a  particular  socket  type using a given address
       family.  However, many protocols may exist, in which  case
       a  particular  protocol  must  be specified.  The protocol
       number to use depends on the _c_o_m_m_u_n_i_c_a_t_i_o_n _d_o_m_a_i_n in which
       communication  is to take place.  _p_r_o_t_o_c_o_l can be supplied
       as zero, in which case the system chooses a protocol  type
       to use.

       Sockets  of  type  SOCK_STREAM are byte streams similar to
       pipes except that they are full-duplex  instead  of  half-
       duplex.   A  stream  socket  must  be in a _c_o_n_n_e_c_t_e_d state
       before any data can be sent or received on it.  A  connec-
       tion  to  another  socket  is created with a _c_o_n_n_e_c_t(3) or
       _a_c_c_e_p_t(3) call.  Once connected, data can  be  transferred
       using  some  variant  of  the  _s_e_n_d(3)  and _r_e_c_v(3) or the
       _r_e_a_d(3) and _w_r_i_t_e(3) calls.  When a session has been  com-
       pleted, a _c_l_o_s_e(3) can be performed.

       A  SIGPIPE signal is raised if a process sends on a broken
       stream; this causes naive processes that do not handle the



                             MiNT-Net                           1





socket(3)                                               socket(3)


       signal  to  exit.   An  end-of-file  condition (zero bytes
       read) is returned if a process tries to read on  a  broken
       stream.

       SOCK_DGRAM sockets allow sending of messages to correspon-
       dents named in _s_e_n_d(3) calls.   It  is  also  possible  to
       receive messages at such a socket with _r_e_c_v(3).

       The  operation  of  sockets  is controlled by socket level
       options set by the _s_e_t_s_o_c_k_o_p_t library  call  described  by
       the  _g_e_t_s_o_c_k_o_p_t(3)  reference  page.   These  options  are
       defined in the file <ssyyss//ssoocckkeett..hh> and  explained  in  the
       _g_e_t_s_o_c_k_o_p_t _(_3_) reference page.

RREETTUURRNN VVAALLUUEE
       If  the call is successful, a valid file descriptor refer-
       encing the  socket  is  returned.   If  it  fails,  -1  is
       returned and an error code is stored in eerrrrnnoo.

DDIIAAGGNNOOSSTTIICCSS
       _s_o_c_k_e_t fails if:

       [ENOENT]                 The  socket device driver has not
                                been started.

       [EAFNOSUPPORT]           The specified address  family  is
                                not supported.

       [ESOCKTNOSUPPORT]        The  specified socket type is not
                                supported in this address family.

       [EPROTONOSUPPORT]        The  specified  protocol  is  not
                                supported.

       [EMFILE]                 The per-process descriptor  table
                                is full.

       [ENOMEM]                 No  buffer  space  is  available.
                                The socket cannot be created.

       [EPROTOTYPE]             The type of socket  and  protocol
                                do not match.

SSEEEE AALLSSOO
       accept(3),  bind(3),  connect(3), getsockname(3), getsock-
       opt(3), ioctl(3), listen(3), recv(3), select(3),  send(3),
       shutdown(3).










                             MiNT-Net                           2


