nd is a small software that allows you to create simple network daemons.
Usage: ./nd -p port [OPTIONS]... command...
Listen on a TCP port, executing a command with stdin and stdout redirecting to the incoming connection.
-p port The port to run the server on.
-a addr The address to ind the server to.
-v Print additional output.
-d Daemonize the server.
-i Block SIGPIPE for child processes.
-l logfile Redirect output to logfile.
-x pidfile Write out the PID of the server to pidfile.
-u user Run child processes as user.
-U user After binding to the address, switch to user.
-k Do not kill child processes when server is killed.
-h Print this help.
A simple daemon can be created like this:
$ nd -p 4000 echo hi
With this running, whenever a client connects they will see the string ’hi’ printed, and then the connection will close.
The following shows how to run nd as a daemon:
$ nd -p 4000 -l log -x pid -d -v echo hi
This will tell nd to daemonize itself. The pid of the daemon will be written to pid and the logging will be redirected to log. The -v parameter increases the verbosity slightly. With one -v parameter, the server startup sequence is logged and an additional log line is written when the server stops.
nd can be stopped by sending either SIGINT or SIGTERM to the process. SIGINT is usually ^C at a terminal, whereas SIGTERM is the default sent by kill. Note that these will also stop any running child processes unless -k was passed to nd at startup.
The following environment variables are set for child processes.
The remote port of the client
The remote address of the client
The port nd is bound to
The address nd is bound to
The number of -v parameters passed to nd
What's New in This Release:
· Many features were implemented.
· IPv6 support is missing.