From b417bcc57b9fd49f360087c32c97293a6bc7d2be Mon Sep 17 00:00:00 2001 From: sotech117 Date: Wed, 20 Sep 2023 15:47:42 -0400 Subject: reverse handshake --- client.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'client.c') 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; -- cgit v1.2.3-70-g09d2