#ifndef SERVER_H #define SERVER_H #include #define LISTEN_ALL // define to listen on 0.0.0.0, else loopback #define MAX_CLIENTS 100 // how many clients the server can handle /* Details for each client, used by Dispatcher and passed to client threads */ struct client_details { int id, sockid; int pipe[2]; pthread_t listener_thread, sender_thread; }; /* Handle command line arguments */ int handle_args(int, char**); /* Compute the next free client_id in the client array */ int get_next_free_client_id(void); /* Disconnect a client using its client id */ int disconnect_client(int); /* Thread, parses and handles messages */ void *Dispatcher(void*); /* Thread, listens for incoming messages */ void *ClientListener(void*); /* Thread, sends messages to the client */ void *ClientSender(void*); /* Handles a client after its connection */ void service(int); /* Handler for signal() */ void interrupt(int); #endif