diff --git a/src/chat/client/main.c b/src/chat/client/main.c index 9ff39c5..c7510ff 100644 --- a/src/chat/client/main.c +++ b/src/chat/client/main.c @@ -45,7 +45,11 @@ int main(void) send_socket(line, listen_socket); - if (strcmp(line, "!exit") == 0) break; //USER REQUESTED PROGRAM EXIT + if (strcmp(line, "!exit\n") == 0) //USER REQUESTED PROGRAM EXIT + { + printf("Exiting...\n"); + break; + } } free(line); //TODO: Unreachable; add exit diff --git a/src/chat/server/main.c b/src/chat/server/main.c index 1a46d13..f29ece8 100644 --- a/src/chat/server/main.c +++ b/src/chat/server/main.c @@ -62,6 +62,8 @@ int main(void) void *communicate_thread(void *arg) { + printf("User connected.\t%d\n", *((int*) arg)); + const time_t startTime = time(NULL); while (time(NULL) - startTime < 86400) //KEEP COMMUNICATION ALIVE FOR 24 HOURS @@ -70,13 +72,15 @@ void *communicate_thread(void *arg) if (received == NULL) return NULL; //FAILED; EXIT THREAD - if (strcmp(received, "!exit") == 0) break; //USER REQUESTED PROGRAM EXIT + if (strcmp(received, "!exit\n") == 0) break; //USER REQUESTED PROGRAM EXIT printf("Received:\n%s\n\n", received); why2_deallocate(received); } + printf("User exited.\t%d\n", *((int*) arg)); + close(*((int*) arg)); return NULL; }