LISTEN(1)                                               LISTEN(1)

     NAME
          listen, dial - network connections

     SYNOPSIS
          listen [ -A ] [ -a alg ]... [ -f keyfile ] [ -i {initscript}
          ] [ addr {command} ]...
          dial [ -A ] [ -a alg ] [ -f keyfile ] addr {command}

     DESCRIPTION
          Listen waits for an incoming network connection on any given
          addr, (as accepted by announce in sys-dial(2)) and then
          invokes sh(1) to run the associated command. If the -A
          option is specified, no authentication or encryption will
          take place on the connection; otherwise listen will attempt
          to authenticate the party at the other end of the connec-
          tion, allowing any given alg to be used to encrypt and/or
          digest the connection's data.. If neither -A or any -a
          option is given, then listen will allow any algorithm
          allowed by the local ssl(3) device.  If keyfile is speci-
          fied, then it will be used as the server's certificate; oth-
          erwise /usr/user/keyring/default will be used.  If an
          initscript is provided, it is executed by each listener
          after announcing its network connection, with the shell
          variable net set to the name of the corresponding network
          directory (see sys-dial(2)), before listening for incoming
          calls.

          Dial is the complement of listen. It tries to make a connec-
          tion to addr. If the -A option is given, no authentication
          or encryption will take place; otherwise Inferno authentica-
          tion and encryption will be performed as usual, using alg if
          given, or a default algorithm otherwise.  Keyfile is used
          for the certificate if given, otherwise
          /usr/user/keyring/addr, if it exists, and failing that,
          /usr/user/keyring/default.  Alg is used for the
          encryption/digest algorithm on the connection.  When the
          connection is made, command is run in the context of that
          connection, as described below.

          For both dial and listen, when the command is run, $user is
          set to the name of the authenticated user at the other end
          of the connection (if authentication is being used), and
          $net is set to the /net directory corresponding to the con-
          nection.  The standard input and output of the command is
          redirected to the network connection (standard error is
          unaffected).

     EXAMPLE
          Run a custom login daemon and an echo server that logs
          incoming connections:

     Page 1                       Plan 9            (printed 12/21/24)

     LISTEN(1)                                               LISTEN(1)

          listen (
               'tcp!*!echo' {
                    echo got connection from `{cat $net/remote} >[1=2]
                    cat
               }
               'tcp!*!inflogin' {
                    customlogind
               }
          )
          Dial up the above echo server:
          dial tcp!somehost!echo {echo made connection >[1=2]; echo hello}

     SOURCE
          /appl/cmd/listen.b

     SEE ALSO
          srv(8), sys-dial(2)

     Page 2                       Plan 9            (printed 12/21/24)