From 97b4913de92b150ca18690df1b41e62c856aab05 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Fri, 15 Sep 2023 01:20:36 -0400 Subject: cleanup the hello and welcome interactoin --- client.c | 4 +++- snowcast_server | Bin 34476 -> 34476 bytes snowcast_server.c | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 49d2cdf..cb524cf 100644 --- a/client.c +++ b/client.c @@ -113,12 +113,14 @@ int main(int argc, char *argv[]) if (line == NULL) { continue; } else if (strncmp("q\n", input, LINE_MAX) == 0) { + // end code if type in q printf("Exiting.\n"); break; } else { // convert input to an int int inputInt = (uint16_t)atoi(input); - + + // send the command to change the station struct SetStation setStation; setStation.commandType = 1; setStation.stationNumber = htons(inputInt); diff --git a/snowcast_server b/snowcast_server index 1f61e9d..395e06e 100755 Binary files a/snowcast_server and b/snowcast_server differ diff --git a/snowcast_server.c b/snowcast_server.c index f09bfcc..e8f9525 100644 --- a/snowcast_server.c +++ b/snowcast_server.c @@ -138,6 +138,7 @@ int main(int argc, char *argv[]) get_in_addr((struct sockaddr*)&remoteaddr), remoteIP, INET6_ADDRSTRLEN), newfd); + // send the welcome message to client struct Welcome welcome; welcome.replyType = 2; @@ -160,8 +161,12 @@ int main(int argc, char *argv[]) FD_CLR(i, &master); // remove from master set } else { // we got some data from a client + if (command.commandType == 0) { + // hello message with udpPort + printf("udpPort (from Hello) for new connection is %d.\n", ntohs(command.number)); + } if (command.commandType == 1) { - // update the station for the user + // setStation command for the user printf("TODO: set station to %d\n", ntohs(command.number)); } else { -- cgit v1.2.3-70-g09d2