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.
Option Summary:
-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.
EXAMPLES
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.
Daemonizing
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.
Stopping nd
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.
ENVIRONMENT
The following environment variables are set for child processes.
ND_PORT
The remote port of the client
ND_ADDR
The remote address of the client
ND_LISTEN_PORT
The port nd is bound to
ND_LISTEN_ADDR
The address nd is bound to
ND_VERBOSITY
The number of -v parameters passed to nd
What's New in This Release:
· Many features were implemented.
· IPv6 support is missing.
Product's homepage