man(1) Manual page archive

     SYS-DIAL(2)                                           SYS-DIAL(2)

          announce, dial, listen - make network connections

          include "sys.m";
          sys := load Sys Sys->PATH;

          Connection: adt
              dfd:  ref FD;  # data file
              cfd:  ref FD;  # control file
              dir:  string;  # pathname of line directory

          announce: fn(addr: string):           (int, Connection);
          dial:     fn(addr, local: string):    (int, Connection);
          listen:   fn(c: Connection):          (int, Connection);

          These routines establish network connections.  Their
          description uses the following definitions:

          addr     is a network address in one of the following forms:


          network  Any directory listed in /net (eg, tcp), or the spe-
                   cial token, net.  The name net acts as a free vari-
                   able that stands for any network in common between
                   the source and netaddr. A network name can be pre-
                   ceded by the full path name of a directory of net-
                   works, using the form /dir/network (eg,

          netaddr  A host name, a domain name, a network address, or a
                   meta-name of the form $attribute, which is replaced
                   by value from the corresponding attribute-value
                   pair in the connection server data base (see

          The functions dial and announce translate a given addr to an
          actual network address using the connection server cs(8). If
          a logical name addr corresponds to several network
          addresses, for instance if a destination machine has several
          interfaces, cs will return them all.  In particular, if addr
          is net, cs will return addresses on all networks that are
          common to source and destination.  The translation procedure

     SYS-DIAL(2)                                           SYS-DIAL(2)

          accesses cs using its interface file cs, which is sought as
          follows: first, in an explicit directory /dir if one was
          given in network; second, in the standard directory /net;
          and finally in the directory /net.alt (dial only).  If the
          connection server cannot be found, the addr is used as-is.

          If a connection attempt is successful, the dir member of the
          resulting Connection will be the path name of a line
          directory that has files for accessing the connection.  One
          line directory exists for each possible connection.  The
          data file in the line directory is opened to make a connec-
          tion, and read and written to communicate with the destina-
          tion.  The ctl file in the line directory can be used to
          send commands to the line.  See ip(3) for messages that can
          be written to the ctl file.  The last close of the data or
          ctl file will close the connection.  The remote file in the
          line directory contains the address called; the file local
          contains the local address assigned.

          The dial routine makes a call to destination addr on a mul-
          tiplexed network.  If the connection server returns several
          addresses, dial tries each in turn, until a connection is
          made or no addresses remain to be tried.  It returns a
          Connection containing a file descriptor dfd open for reading
          and writing the data file in the line directory, and a file
          descriptor cfd open for reading and writing the ctl file.
          If local is non-empty, and the network allows the local
          address to be set, as is the case with UDP and TCP port num-
          bers, the local address will be set to local.

          Announce and listen are the complements of dial.  Announce
          establishes a network name to which incoming calls can be
          made.  In addr, netaddr gives the name or address of one of
          the local host's interfaces on which to listen for calls to
          the given service; it can be * to listen for calls on any
          interface on network. Announce returns a Connection struc-
          ture in which only the cfd descriptor is open, on the con-
          trol file representing the announcement.  Listen takes as
          its only argument the Connection structure of a successful
          call to announce.  When a call is received, listen returns
          an open Connection structure as if from dial, except that
          only the cfd descriptor is open, dfd is nil, and the caller
          must open the data file for itself.

          Make a call and return an open file descriptor to use for

               callkremvax(): (int, Connection)
                    return sys->dial("tcp!kremvax!80", nil);

     SYS-DIAL(2)                                           SYS-DIAL(2)

          Call the local certificate signer:

               dialsigner(service: string): (int, Connection)
                    return sys->dial("net!$SIGNER!inflogin", nil);


          The integer valued functions return 0 on success and -1 on
          error; the system error string is set.  The integer compo-
          nent of the tuple returned by the other functions follows
          the same convention.

          Note that listen does not open the data file.