diff --git a/src/chat/client/main.c b/src/chat/client/main.c index ac452eb..9ff39c5 100644 --- a/src/chat/client/main.c +++ b/src/chat/client/main.c @@ -44,6 +44,8 @@ int main(void) printf("%s\n", line); send_socket(line, listen_socket); + + if (strcmp(line, "!exit") == 0) break; //USER REQUESTED PROGRAM EXIT } free(line); //TODO: Unreachable; add exit diff --git a/src/chat/server/main.c b/src/chat/server/main.c index d04720d..1a46d13 100644 --- a/src/chat/server/main.c +++ b/src/chat/server/main.c @@ -18,6 +18,8 @@ along with this program. If not, see . #include +#include + char *read_socket(int socket); void *communicate_thread(void *arg); @@ -68,11 +70,14 @@ void *communicate_thread(void *arg) if (received == NULL) return NULL; //FAILED; EXIT THREAD + if (strcmp(received, "!exit") == 0) break; //USER REQUESTED PROGRAM EXIT + printf("Received:\n%s\n\n", received); why2_deallocate(received); } + close(*((int*) arg)); return NULL; }