NAME

run_service -- run a TCP-based service on a given hostport

SYNOPSIS

   #include <afblib/service.h>

   typedef void (*session_handler)(int fd, int argc, char** argv);

   void run_service(hostport* hp, session_handler handler,
      int argc, char** argv);

DESCRIPTION

run_service creates a socket with the given address specified by hp (see hostport), and accepts connections. For each accepted connection, a process is spawned that invokes the provided handler which is called with the provided arguments argc and argv. As soon the session handler returns, the spawned off process terminates with an exit code of 0.

run_service terminates only in case of errors. SA_NOCLDWAIT is set for SIGCHLD such that all forked-off processes do not become zombies.

AUTHOR

Andreas F. Borchert