[Top] [Prev] [Next]


announce, dial, export, 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);
export:   fn(fd: ref FD, flag: int):  int;


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

An network address in one of the following forms:

network!machine!service network!netaddr netaddr


Any directory listed in /net or the special token, net.


A free variable that stands for any network in common between the source and the host netaddr. The netaddr portion can be a host name, a domain name, a network address, or a meta-name of the form $attribute, which is resolved according to the information specified in the file /cs/db.

If a connection attempt is successful dir is 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 should be used to communicate with the destination.


The ctl file in the line directory can be used to send commands to the line. See ip for messages that can be written to the ctl file. The last close of the data or ctl file will close the connection.


(addr, local)

The dial routine makes a call to destination addr on a multiplexed network. If the network in addr is net, dial will try in succession all networks in common between source and destination until a call succeeds. It returns a file descriptor open for reading and writing the data file in the line directory. The addr file in the line directory contains the address called. If the network allows the local address to be set, as is the case with UDP and TCP port numbers, and local is non-empty, the local address will be set to local.


(addr) and


The announce and listen functions are the complements of dial. The announce function establishes a network name to which incoming calls can be made. Like dial, announce returns an open Connection abstract data type (adt). The listen function takes as its only argument the Connection adt of a successful call to announce. When a call is received, listen returns an open Connection adt as if from dial.


(fd, flag)

The export function responds to client requests for file operations on the server's file name space. This is the server end of a client's mount call. Typically, export's first argument is the dfd member of a Connection returned from listen. The export function can take two mutually exclusive flags


The export function blocks until all client requests are complete.


Client requests are handled by a background thread while export returns immediately


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

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

Call the local authentication server:

dialauth(service: string): (int, Connection) { return sys->dial("net!$auth", nil); }

See Also

Discussion of the mount function

[Top] [Prev] [Next]

Copyright © 1996,Lucent Technologies, Inc. All rights reserved.