NAME
listen, listen1, tcp7, tcp9, tcp19, tcp21, tcp23, tcp25, tcp110, tcp113, tcp143, tcp445, tcp513, tcp515, tcp564, tcp565, tcp566, tcp567, tcp993, tcp995, tcp1723, tcp17019, tcp17020 – listen for calls on a network device

SYNOPSIS
aux/listen [–iq] [–d srvdir] [–t trustsrvdir] [–n namespace] [–p maxprocs] [–o copt] [–O sopt] [–a addr] [proto]

aux/listen1 [ –1tv ] [–n namespace] [–p maxprocs] [–o copt] [–O sopt] addr cmd [ args... ]

DESCRIPTION
Listen listens on a network for inbound calls to local services. Proto is the network protocol on which to listen, by default tcp. Incoming calls to any address * are accepted unless addr is specified with the –a option. The services available are executable, non–empty files in srvdir or trustsrvdir. If neither srvdir nor trustsrvdir is given, listen looks for executable files in /bin/service. Services found in srvdir are executed as user none; services found in trustsrvdir are executed as the user who started listen. When changing user to none, a new namespace is created, usually by executing /lib/namespace, but –n selects an alternate namespace. The –p option limits the number of processes that listen spawns to service the connections. If the maxprocs limit is reached, listen will log the event and delay servicing until the number of connection processes drops below the limit again. A maxprocs smaller or equal zero means no limit (default). The –o and –O options cause protocol–specific control messages to be written to the control file of the listening server connection –O or the incoming client connection –o. They can be specified multiple times. See ip(3) for details. Option –q suppresses affirmative log information. Option –i suppresses the periodic scan of the service directories for changes.

Service names are made by concatenating the name of the network with the name of the service or port. For example, an inbound call on the TCP network for port 565 executes service tcp565.

Services may have individual namespace(6) files specified within srvdir. If provided, the namespace is used as the parent for each connection to the corresponding service. Namespace files are found by appending a .namespace suffix to the service name.

At least the following services are available in /bin/service.
tcp564     serve a piece of the name space using the Plan 9 file system protocol, with authentication via Tauth (in attach(5)), no encryption, and multiplex multiple users on a single connection (used by srv(4), and also by Unix systems to see Plan 9 files).
tcp17019   server for rcpu(1), replaces rx, import and cpu using TLS for encryption.
tcp17020   TLS encrypted 9P fileserver (t9fs) for srvtls (see srv(4)).
tcp7       echo any bytes received (bit mirror)
tcp9       consume any bytes received (bit bucket)
tcp19      chargen service.
tcp21      FTP daemon
tcp23      telnet terminal connection.
tcp25      mail delivery.
tcp110     POP3 port.
tcp113     Ident port (always reports none).
tcp143     IMAP4rev1 port.
tcp445     CIFS/SMB file sharing.
tcp513     rlogin terminal connection.
tcp515     LP daemon; see lp(8).
tcp565     report the address of the incoming call.
tcp993     Secure IMAP4rev1 port.
tcp995     Secure POP3 port.
tcp1723    PPTP (point–to–point tunnelling protocol) service.

At least the following services are available in /bin/service.auth, the usual trustsrvdir.
tcp566     validate a SecureNet box.
tcp567     Plan 9 authentication–ticket service.

Listen1 is a lightweight listener intended for personal use, modeled from Inferno's listen(1). It announces on address, running cmd args... for each incoming connection; the network directory is passed in the environment as $net. Option –t causes listen1 to run as the invoking user; the default is to become none before listening. Option –1 arms a one–shot listener; it terminates listen1 upon receiving a single call. Option –v causes verbose logging on standard output. See /rc/bin/tlssrvtunnel for an example.

FILES
/net/tcp       by convention, TCP device bind point

SOURCE
/sys/src/cmd/aux/listen*.c
/rc/bin/service*

SEE ALSO
authsrv(6), dial(2), ip(3)

BUGS
Srvdir, trustsrvdir and namespace must all be absolute path names.