added way to exit client
This commit is contained in:
parent
5b855d21bd
commit
62fc06ab52
@ -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
|
||||
|
@ -18,6 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <why2/chat/common.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user