aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-15 01:22:05 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-15 01:22:05 -0400
commit35f464738c990752ffdb65ef3adcb2812925c07d (patch)
tree2abd525f5b30d6ab11dd0b2a2052fc322dff2b52
parent97b4913de92b150ca18690df1b41e62c856aab05 (diff)
small cleanup
-rw-r--r--snowcast_server.c17
1 files 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