added basic input thread function

This commit is contained in:
2025-07-08 21:40:43 -06:00
parent d2e6441c96
commit 503ab912f8
+8 -2
View File
@@ -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];