![]() | :: | Software | :: | ucspi-tcphandle |
The tcphandle.c program provides a framework for compiling preforking tcpserver-like servers.
Each tcphandle server accepts all tcpserver options, and in addition:
-f lockfile: Lock lockfile around calls to accept.
The concurrency option (-c) sets the number of children that a tcphandle server forks upon startup. The default setting is 40. Each child process listens for requests on the socket inherited from the parent process.
If any of its child processes exits, a tcphandle server forks a new child process to replace the original. When it receives SIGTERM, a tcphandle server sends SIGTERM to each of its children, waits for them to exit, and then itself exits.
Before handling an accepted request, a tcphandle server sets certain environment variables, a la tcpserver.
void server(int argc,char * const *argv)The arguments to server are the command line arguments to the tcphandle server that remain after option parsing.
The server subroutine is called within a loop, with one iteration per request. It must release any resources allocated to handle a particular request before returning to its caller. This includes changes to the environment.
build myserver
The ucspi-tcphandle package includes two example servers: tcpprint, and tcpperl.