aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-20 15:47:42 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-20 15:47:42 -0400
commitb417bcc57b9fd49f360087c32c97293a6bc7d2be (patch)
treea514e5c211c6c9f677780c11126f44b4be2806aa /client.c
parentd56008a0f0e92cadb51437f723150d9e6a3c9f5f (diff)
reverse handshake
Diffstat (limited to 'client.c')
-rw-r--r--client.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/client.c b/client.c
index 0825abb..d24b02a 100644
--- a/client.c
+++ b/client.c
@@ -80,16 +80,6 @@ int main(int argc, char *argv[])
// printf("client: connecting to %s\n", s);
freeaddrinfo(servinfo); // all done with this structure
-
- struct Welcome msg;
- // recv the message, check for errors too
- if ((recvbytes = recv(sockfd, (char*)&msg, sizeof(struct snowcast_message), 0)) == -1) {
- perror("recv");
- exit(1);
- }
- msg.numStations = ntohs(msg.numStations);
- printf("Welcome to Snowcast! The server has %d stations\n", msg.numStations);
-
struct Hello hello;
hello.commandType = 0;
// convert updPort to an int
@@ -100,6 +90,16 @@ int main(int argc, char *argv[])
perror("send");
exit(1);
}
+
+ struct Welcome msg;
+ // recv the message, check for errors too
+ if ((recvbytes = recv(sockfd, (char*)&msg, sizeof(struct snowcast_message), 0)) == -1) {
+ perror("recv");
+ exit(1);
+ }
+ msg.numStations = ntohs(msg.numStations);
+ printf("Welcome to Snowcast! The server has %d stations.\n", msg.numStations);
+
close(sockfd);
return 0;