pthr_server_main - server framework |
#include <pthr_server_main.h> void pthr_server_main (const char *name, void (*processor_fn) (int sock, struct sockaddr_in addr), void (*global_fn) (void), int port, int fork_into_background, int close_io, int chdir_root) __attribute__((noreturn)); |
pthr_server_main is a convenient framework function for writing servers quickly using pthrlib. It creates a listener thread which listens on the given port number and throws off new processor threads to handle each incoming connection. |
name is the name of the server. |
processor_fn is a function which should create a new processor thread for each incoming connection. |
global_fn is called after forking, but before starting to accept new connections. It should perform any necessary initialization. |
port is the port number to listen on. |
fork_into_background should be set if the process should fork into the background (this is normally desirable for server processes). |
close_io should be set if the process should close file descriptors 0, 1 and 2 before starting up. |
chdir_root should be set if the process should change to the root directory before starting up. |
Richard Jones <rich@annexia.org> |
GNU LGPL (see http://www.gnu.org/) |
pthrlib-2.2.2 |