diff --git a/src/server.c b/src/server.c index 882767c..81cf2e5 100644 --- a/src/server.c +++ b/src/server.c @@ -129,6 +129,12 @@ int main(int argc, char *argv[]) { } } + /* Disconnect all clients before closing the server */ + for (int i = 0; i < MAX_CLIENTS; i++) { + write(clients[i].sockid, "disconnect command", 0); // TODO: decide a disconnect command to send + disconnect_client(i); + } + printf("Server end, closing connection\n"); (void) pthread_join(dispatcher, &retval); close(serv_sockid);