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;
network!destination!serviceport
For more information about the structure of this address, see Request Format in Chapter 6
The Connection Server
If the connection server is running, the dial function will pass addr to that daemon for the translation of host names, symbolic service names, and so on, to addresses of the designated network (the first component). See cs - connection server daemon for description of the supported conversion.
If the connection server daemon is not running, the dial function silently skips the translation stage and attempts to open a network connection with addr as received.
At the completion of dial, local can be read from the local file of the network interface.
On failure, the dial function returns -1 in the integer portion of the tuple.
On success, the members of the returned Connection adt have been initialized to the following values:
See the appropriate Network device pages (for example, ip - TCP, UDP network protocols over IP in Chapter 2) for further details of using this interface.
announce (addr)
The announce function and the listen function described in this section are the complements of the dial function. Their actions allow completion of connection requests from clients using the dial function. The Argument, addr
The announce function establishes a network name (service port) to which incoming calls can be made. The format of the addr, the single argument is: The Connection Server
The announce function uses the connection server to translate any symbolic components of the argument to values acceptable to the network. See the cs daemon for a description of the supported translations.
When a call is received, listen includes an open Connection adt that leads to a network interface file. The data file of that interface is cross connected (read-to-write and write-to-read) to the data file associated with the Connection adt returned by the dial function to the client process.
Requests for pathname resolution occur relative to the current root directory of the process calling export. That process can control the set of files available for mounts requests by clients by defining the root directory of its name space using the operations described on the bind page.
The export function can take two mutually exclusive flags
EXPWAIT
|
The export function blocks until all client requests are complete.
|
EXPASYNC
|
Client requests are handled by a background thread, while export returns immediately
|
Return Values
The export function returns 0 on success and -1 on failure. Examples
Make a call and return an open file descriptor to use for communications:
callkremvax( ): (int, Connection) { return sys->dial("tcp!kremvax!mpeg", nil); }Call the local authentication server:
dialauth(service: string): (int, Connection) { return sys->dial("net!$SIGNER!inflogin", nil); }
bind, mount, unmount - change file name space
|
cs - connection server daemon in Chapter 6
|