aboutsummaryrefslogtreecommitdiffstats
s6-networking: the s6-tcpserver6d program

s6-networking
Software
skarnet.org

The s6-tcpserver6d program

s6-tcpserver6d is the serving part of the s6-tcpserver6 super-server. It assumes that its stdin is a bound and listening TCP/IPv6 socket, and it accepts connections from clients connecting to it, forking a program to handle each connection.

Interface

     s6-tcpserver6d [ -1 ] [ -v verbosity ] [ -c maxconn ] [ -C localmaxconn ] prog...
  • s6-tcpserver6d accepts connections from clients to an already bound and listening TCP socket which is its standard input.
  • For every TCP connection to this socket, it forks. The child sets some environment variables, then executes prog... with stdin reading from the network socket and stdout writing to it.
  • Depending on the verbosity level, it logs what it does to stderr.
  • It runs until killed by a signal. Depending on the received signal, it may kill its children before exiting.

Environment variables

For each connection, an instance of prog... is spawned with the following variables set:

  • PROTO: always set to TCP
  • TCPREMOTEIP: set to the originating address
  • TCPREMOTEPORT: set to the originating port
  • TCPCONNNUM: set to the number of connections originating from the same IP address

Options

  • -1 : write a newline to stdout, and close stdout, right before entering the client-accepting loop. If stdout is suitably redirected, this can be used by monitoring programs to check when the server is accepting connections, for instance s6's readiness notification mechanism.
  • -v verbosity : be more or less verbose. By default, verbosity is 1: print warning messages to stderr. 0 means only print fatal error messages ; 2 means print status and connection information for every client.
  • -c maxconn : accept at most maxconn concurrent connections. Default is 40. It is impossible to set it higher than 1000.
  • -C localmaxconn : accept at most localmaxconn connections from the same IP address. Default is 40. It is impossible to set it higher than maxconn.

Signals

  • SIGTERM: exit.
  • SIGHUP: send a SIGTERM and a SIGCONT to all children.
  • SIGQUIT: send a SIGTERM and a SIGCONT to all children, then exit.
  • SIGABRT: send a SIGKILL to all children, then exit.

Notes

  • Unlike its ancestor tcpserver, s6-tcpserver6d performs just the bare minimum: the point is to have a very small and very fast process to serve connections with the least possible overhead. Features such as additional environment variables, access control and DNS resolution are provided via the s6-tcpserver-access program.
  • s6-tcpserver6d is meant to be execve'd into by a program that gets the listening socket. That program is normally s6-tcpserver6-socketbinder, which creates the socket itself; but it can be a different one if the socket is to be retrieved by another means, for instance by fd-passing from a fd-holding daemon (some people call this "socket activation").