elisp: Network Processes

 
 36.17.1 ‘make-network-process’
 ------------------------------
 
 The basic function for creating network connections and network servers
 is ‘make-network-process’.  It can do either of those jobs, depending on
 the arguments you give it.
 
  -- Function: make-network-process &rest args
      This function creates a network connection or server and returns
      the process object that represents it.  The arguments ARGS are a
      list of keyword/argument pairs.  Omitting a keyword is always
      equivalent to specifying it with value ‘nil’, except for ‘:coding’,
      ‘:filter-multibyte’, and ‘:reuseaddr’.  Here are the meaningful
      keywords (those corresponding to network options are listed in the
      following section):
 
      :name NAME
           Use the string NAME as the process name.  It is modified if
           necessary to make it unique.
 
      :type TYPE
           Specify the communication type.  A value of ‘nil’ specifies a
           stream connection (the default); ‘datagram’ specifies a
           datagram connection; ‘seqpacket’ specifies a sequenced packet
           stream connection.  Both connections and servers can be of
           these types.
 
      :server SERVER-FLAG
           If SERVER-FLAG is non-‘nil’, create a server.  Otherwise,
           create a connection.  For a stream type server, SERVER-FLAG
           may be an integer, which then specifies the length of the
           queue of pending connections to the server.  The default queue
           length is 5.
 
      :host HOST
           Specify the host to connect to.  HOST should be a host name or
           Internet address, as a string, or the symbol ‘local’ to
           specify the local host.  If you specify HOST for a server, it
           must specify a valid address for the local host, and only
           clients connecting to that address will be accepted.
 
      :service SERVICE
           SERVICE specifies a port number to connect to; or, for a
           server, the port number to listen on.  It should be a service
           name that translates to a port number, or an integer
           specifying the port number directly.  For a server, it can
           also be ‘t’, which means to let the system select an unused
           port number.
 
      :family FAMILY
           FAMILY specifies the address (and protocol) family for
           communication.  ‘nil’ means determine the proper address
           family automatically for the given HOST and SERVICE.  ‘local’
           specifies a Unix socket, in which case HOST is ignored.
           ‘ipv4’ and ‘ipv6’ specify to use IPv4 and IPv6, respectively.
 
      :local LOCAL-ADDRESS
           For a server process, LOCAL-ADDRESS is the address to listen
           on.  It overrides FAMILY, HOST and SERVICE, so you might as
           well not specify them.
 
      :remote REMOTE-ADDRESS
           For a connection, REMOTE-ADDRESS is the address to connect to.
           It overrides FAMILY, HOST and SERVICE, so you might as well
           not specify them.
 
           For a datagram server, REMOTE-ADDRESS specifies the initial
           setting of the remote datagram address.
 
           The format of LOCAL-ADDRESS or REMOTE-ADDRESS depends on the
           address family:
 
              - An IPv4 address is represented as a five-element vector
                of four 8-bit integers and one 16-bit integer ‘[A B C D
                P]’ corresponding to numeric IPv4 address A.B.C.D and
                port number P.
 
              - An IPv6 address is represented as a nine-element vector
                of 16-bit integers ‘[A B C D E F G H P]’ corresponding to
                numeric IPv6 address A:B:C:D:E:F:G:H and port number P.
 
              - A local address is represented as a string, which
                specifies the address in the local address space.
 
              - An unsupported-family address is represented by a cons
                ‘(F . AV)’, where F is the family number and AV is a
                vector specifying the socket address using one element
                per address data byte.  Do not rely on this format in
                portable code, as it may depend on implementation defined
                constants, data sizes, and data structure alignment.
 
      :nowait BOOL
           If BOOL is non-‘nil’ for a stream connection, return without
           waiting for the connection to complete.  When the connection
           succeeds or fails, Emacs will call the sentinel function, with
           a second argument matching ‘"open"’ (if successful) or
           ‘"failed"’.  The default is to block, so that
           ‘make-network-process’ does not return until the connection
           has succeeded or failed.
 
      :stop STOPPED
           If STOPPED is non-‘nil’, start the network connection or
           server in the stopped state.
 
      :buffer BUFFER
           Use BUFFER as the process buffer.
 
      :coding CODING
           Use CODING as the coding system for this process.  To specify
           different coding systems for decoding data from the connection
           and for encoding data sent to it, specify ‘(DECODING .
           ENCODING)’ for CODING.
 
           If you don’t specify this keyword at all, the default is to
           determine the coding systems from the data.
 
      :noquery QUERY-FLAG
           Initialize the process query flag to QUERY-FLAG.  SeeQuery
           Before Exit.
 
      :filter FILTER
           Initialize the process filter to FILTER.
 
      :filter-multibyte MULTIBYTE
           If MULTIBYTE is non-‘nil’, strings given to the process filter
           are multibyte, otherwise they are unibyte.  The default is the
           default value of ‘enable-multibyte-characters’.
 
      :sentinel SENTINEL
           Initialize the process sentinel to SENTINEL.
 
      :log LOG
           Initialize the log function of a server process to LOG.  The
           log function is called each time the server accepts a network
           connection from a client.  The arguments passed to the log
           function are SERVER, CONNECTION, and MESSAGE; where SERVER is
           the server process, CONNECTION is the new process for the
           connection, and MESSAGE is a string describing what has
           happened.
 
      :plist PLIST
           Initialize the process plist to PLIST.
 
      The original argument list, modified with the actual connection
      information, is available via the ‘process-contact’ function.