diff --git a/README.md b/README.md new file mode 100644 index 0000000..d71e959 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +Chatty is a simple, multithreaded chat program by Dane MacFadden. +It's inspired by an assignment I did in university that was a similar project +and is intended to be an exercise in networked and multithreaded programming. +Check out Beej's guide to network programming (and his other guides) if you want +to build something similar. Much of my code is based on his client and server. diff --git a/main.c b/main.c index 8a76e91..82f4f3a 100644 --- a/main.c +++ b/main.c @@ -21,6 +21,8 @@ #define MAXBUFSIZE 30 #define BACKLOG 10 +LIST *receivelist, *sendlist; + void *input(void *arg) { while (1) { /* @@ -59,7 +61,6 @@ int main(int argc, char* argv[]) { char *remote_machine, *local_port, *remote_port; int status, socketfd, confd, len; int yes = 1; - char buf[10]; if (argc != 4) { printf("Wrong number of arguments. Usage: ./chatty \ @@ -71,6 +72,9 @@ int main(int argc, char* argv[]) { remote_machine = argv[2]; remote_port = argv[3]; + receivelist = ListCreate(); + sendlist = ListCreate(); + if (atoi(local_port) < atoi(remote_port)) { /* Congrats, you're the server */ memset(&hints, 0, sizeof(hints));