added connect & exit messages
This commit is contained in:
parent
62fc06ab52
commit
7e77f6ffda
@ -45,7 +45,11 @@ int main(void)
|
|||||||
|
|
||||||
send_socket(line, listen_socket);
|
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
|
free(line); //TODO: Unreachable; add exit
|
||||||
|
@ -62,6 +62,8 @@ int main(void)
|
|||||||
|
|
||||||
void *communicate_thread(void *arg)
|
void *communicate_thread(void *arg)
|
||||||
{
|
{
|
||||||
|
printf("User connected.\t%d\n", *((int*) arg));
|
||||||
|
|
||||||
const time_t startTime = time(NULL);
|
const time_t startTime = time(NULL);
|
||||||
|
|
||||||
while (time(NULL) - startTime < 86400) //KEEP COMMUNICATION ALIVE FOR 24 HOURS
|
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 (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);
|
printf("Received:\n%s\n\n", received);
|
||||||
|
|
||||||
why2_deallocate(received);
|
why2_deallocate(received);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("User exited.\t%d\n", *((int*) arg));
|
||||||
|
|
||||||
close(*((int*) arg));
|
close(*((int*) arg));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user