added basic input thread function
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#define BACKLOG 10
|
||||
|
||||
LIST *receivelist, *sendlist;
|
||||
pthread_mutex_t sendmut, receivemut;
|
||||
|
||||
void *input(void *arg) {
|
||||
char msg[512];
|
||||
@@ -29,7 +30,9 @@ void *input(void *arg) {
|
||||
while (1) {
|
||||
printf("Type a message: ");
|
||||
scanf("%s", msg);
|
||||
printf("%s", msg);
|
||||
pthread_mutex_lock(&sendmut);
|
||||
ListAppend(sendlist, msg);
|
||||
pthread_mutex_unlock(&sendmut);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -52,7 +55,7 @@ void *get_in_addr(struct sockaddr *sa) {
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
pthread_t input_thread, send_thread, receive_thread;
|
||||
pthread_t input_thread, send_thread, receive_thread, output_thread;
|
||||
socklen_t sin_size;
|
||||
struct addrinfo *p, *q;
|
||||
struct addrinfo hints;
|
||||
@@ -70,6 +73,9 @@ int main(int argc, char* argv[]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&sendmut, NULL);
|
||||
pthread_mutex_init(&receivemut, NULL);
|
||||
|
||||
local_port = argv[1];
|
||||
remote_machine = argv[2];
|
||||
remote_port = argv[3];
|
||||
|
||||
Reference in New Issue
Block a user