diff options
Diffstat (limited to 'Server.h')
| -rwxr-xr-x | Server.h | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -5,6 +5,7 @@ #include <netinet/in.h> #include <stdbool.h> #include <pthread.h> +#include <stdatomic.h> struct AcceptedSocket{ int socketFD; @@ -12,7 +13,7 @@ struct AcceptedSocket{ int error; bool succ; pthread_t thread_id; - bool shutdown; + atomic_bool shutdown; struct AcceptedSocket *next; }; @@ -24,25 +25,22 @@ struct Server{ u_long interface; int port; int backlog; - bool running; + atomic_bool running; + + pthread_t server_thread_id; + pthread_t cleanup_thread_id; struct sockaddr_in address; int socket; - char *html_folder; + pthread_mutex_t list_lock; struct AcceptedSocket *accepted_socket; - pthread_t (*launch)(struct Server *server); void (*on_message)(struct Server *server, char message[], ssize_t amountRecv, int socketFD); void (*on_disconnect)(struct Server *server, int socketFD); }; -/* - * AF_INET, SOCK_STREAM, 0, INADDR_ANY, port, 10, launch_socket - * or - * AF_INET, SOCK_STREAM, 0, INADDR_ANY, port, 10, launch - */ -struct Server server_constructor(int domain, int service, int protocol, u_long interface, int port, int backlog, pthread_t (*launch)(struct Server *server)); +struct Server server_constructor(int domain, int service, int protocol, u_long interface, int port, int backlog); #endif /* Server_h */ |
