diff --git a/src/server.c b/src/server.c index 510eebc..2053470 100644 --- a/src/server.c +++ b/src/server.c @@ -13,6 +13,8 @@ * id * pipe * sockid + * listener_thread + * sender_thread * */ struct client_details clients[MAX_CLIENTS]; @@ -40,6 +42,8 @@ int main(int argc, char *argv[]) { clients[i].sockid = -1; clients[i].pipe[0] = -1; clients[i].pipe[1] = -1; + clients[i].listener_thread = -1; + clients[i].sender_thread = -1; } /* Initialize default values for the socket */ @@ -118,6 +122,9 @@ int main(int argc, char *argv[]) { exit(EXIT_FAILURE); } + clients[client_id].listener_thread = clientlistener; + clients[client_id].sender_thread = clientsender; + // TODO: joining here prevents creating other clients, need to move the joins to some client_disconnect function (void) pthread_join(clientsender, &retval); (void) pthread_join(clientlistener, &retval); diff --git a/src/server.h b/src/server.h index dfc7466..341e737 100644 --- a/src/server.h +++ b/src/server.h @@ -1,6 +1,8 @@ #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 @@ -8,6 +10,7 @@ struct client_details { int id, sockid; int pipe[2]; + pthread_t listener_thread, sender_thread; }; /* Handle command line arguments */