aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--client.c5
-rw-r--r--server.c4
-rwxr-xr-xsnowcast_controlbin0 -> 13864 bytes
-rwxr-xr-xsnowcast_serverbin0 -> 14176 bytes
5 files changed, 9 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 5e808ed..23d8e32 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/client.c b/client.c
index 11c462f..adacafe 100644
--- a/client.c
+++ b/client.c
@@ -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");
diff --git a/server.c b/server.c
index c17e039..5bfae9c 100644
--- a/server.c
+++ b/server.c
@@ -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
new file mode 100755
index 0000000..4aa6300
--- /dev/null
+++ b/snowcast_control
Binary files differ
diff --git a/snowcast_server b/snowcast_server
new file mode 100755
index 0000000..05a7e78
--- /dev/null
+++ b/snowcast_server
Binary files differ