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. This can be used to change, or find out the characteristics of an announced port (for instance to find out the actual port number that has been announced).
By default, listen backgrounds itself (after checking that the port announcement proceeded ok); giving it the -s option causes it to run synchronously.
Listen currently makes available the whole of its current name space visible to the command, which might be undesirable, and perhaps should be optional, with a new name space constructed for an incoming call. The -t option declares the command to be `trusted' giving it access to elements of the current name space such as /mnt/keys on an authentication server. By default it has not got that access.
Styxlisten is similar to listen, except that it multiplexes a single styx (see intro(5)) server between multiple clients. Styxlisten starts its cmd only once; it assumes it will serve styx messages through file descriptor 0 when started. For each client that attaches to address, the command will see a new attach(5) message indicating the new connection. Unless the -A option has been given, the uname field in the attach message will be the name of the authenticated user. When the command exits, the process listening on address is stopped.
Dial is the complement of listen. It tries to make a connection to addr. If the -A option is given, no authentication or encryption will take place; otherwise Inferno authentication 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 connection. The standard input and output of the command is redirected to the network connection (standard error is unaffected).
listen 'tcp!*!echo' { echo connection from `{cat $net/remote} >[1=2] echo user is $user >[1=2] cat & }
Dial up the above echo server:
dial tcp!somehost!echo { echo made connection >[1=2]; echo hello; cat >[1=2] }
Make the current name-space available to all:
styxlisten 'tcp!*!styx' export /
LISTEN(1 ) | Rev: Thu Feb 15 14:42:47 GMT 2007 |