From 35f464738c990752ffdb65ef3adcb2812925c07d Mon Sep 17 00:00:00 2001 From: sotech117 Date: Fri, 15 Sep 2023 01:22:05 -0400 Subject: small cleanup --- snowcast_server.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/snowcast_server.c b/snowcast_server.c index e8f9525..b1d7d8a 100644 --- a/snowcast_server.c +++ b/snowcast_server.c @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) printf("TODO: set station to %d\n", ntohs(command.number)); } else { - // send back ianinvalid command + // send back in invalid command struct InvalidCommand invalid; invalid.replyType = 4; invalid.replyStringSize = 21; @@ -178,18 +178,11 @@ int main(int argc, char *argv[]) invalid.replyString = "Invalid command type"; if ((send(i, &invalid, sizeof(struct InvalidCommand), 0)) == -1) perror("send"); + + // drop connection upon invalid command + close(i); + FD_CLR(i, &master); } - // for(j = 0; j <= fdmax; j++) { - // // send to everyone! - // if (FD_ISSET(j, &master)) { - // // except the listener and ourselves - // if (j != listener && j != i) { - // if (send(j, buf, nbytes, 0) == -1) { - // perror("send"); - // } - // } - // } - // } } } // END handle data from client } // END got new incoming connection -- cgit v1.2.3-70-g09d2