diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-09-14 19:16:23 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-09-14 19:16:23 -0400 |
commit | 663580b36a1b2590b7e706baa798e130297e88ee (patch) | |
tree | 3202db0b4e4b50c1d19390ae570ad0ef668cf077 | |
parent | bbfbcc6c936b16568d96619f02f8bb081c190b2a (diff) |
pass all tests on warmup
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | client.c | 5 | ||||
-rw-r--r-- | server.c | 4 | ||||
-rwxr-xr-x | snowcast_control | bin | 0 -> 13864 bytes | |||
-rwxr-xr-x | snowcast_server | bin | 0 -> 14176 bytes |
5 files changed, 9 insertions, 8 deletions
@@ -1,13 +1,13 @@ CC = gcc -CFLAGS = -std=c99 -target x86_64-apple-darwin20 -g -RM = rm -f +# CFLAGS = -std=c99 -target x86_64-apple-darwin20 -g +# CFLAGS = -std=c99 -Wall -g default: all all: server client server: server.c - $(CC) $(CFLAGS) -o server server.c + $(CC) $(CFLAGS) -o snowcast_server server.c client: client.c - $(CC) $(CFLAGS) -o client client.c
\ No newline at end of file + $(CC) $(CFLAGS) -o snowcast_control client.c
\ No newline at end of file @@ -87,11 +87,12 @@ int main(int argc, char *argv[]) perror("recv"); exit(1); } + msg.numStations = ntohs(msg.numStations); // print the num bytes received // printf("client: received '%s'\n", msg); // printf("size of '%d'\n", recvbytes); printf("Welcome to Snowcast! The server has %d stations.\n", msg.numStations); - // printf("type %d", msg.replyType); + // printf("type %d", msg.replyType); // close(sockfd); // if ((numbytesrecv = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) { @@ -107,7 +108,7 @@ int main(int argc, char *argv[]) hello.commandType = 0; // convert updPort to an int int udpPortInt = atoi(udpPort); - hello.udpPort = htonl(udpPortInt); + hello.udpPort = htons(udpPortInt); if ((numbytessent = send(sockfd, &hello, sizeof(struct Hello), 0)) == -1) { perror("send"); @@ -135,10 +135,10 @@ int main(int argc, char *argv[]) close(sockfd); // child doesn't need the listener - // make a struct for the message, number is thennubmer of stations + // make a struct for the message, number is the number of stations struct Welcome welcome; welcome.replyType = 2; - welcome.numStations = argc - 2; + welcome.numStations = htons(argc - 2); if ((b = send(new_fd, &welcome, sizeof(struct Welcome), 0)) == -1) perror("send"); close(new_fd); diff --git a/snowcast_control b/snowcast_control Binary files differnew file mode 100755 index 0000000..4aa6300 --- /dev/null +++ b/snowcast_control diff --git a/snowcast_server b/snowcast_server Binary files differnew file mode 100755 index 0000000..05a7e78 --- /dev/null +++ b/snowcast_server |