clean up the code, remove some of the 'CODE HERE' comments. retesting now.

This commit is contained in:
Charles Descamps 2025-02-20 11:07:06 -07:00
parent b31492b988
commit da93ce1541

View file

@ -48,19 +48,15 @@ int main(int argc, char **argv)
return -1;
}
// use fnctl to set the non-blocking flag for the socket
// CODE HERE
fcntl(socketEchoFD, F_SETFL, O_NONBLOCK);
// the server will now accept client connections by listening.
listen(socketEchoFD, MAX_CONNECT_QUEUE);
// create a file descriptor set, to keep track of the sockets in use using fd_set and FD_ZERO?
// CODE HERE
fd_set socketList;
FD_ZERO(&socketList);
// add the socketEchoFD to the file descriptor set using fd_set
// CODE HERE
FD_SET(socketEchoFD, &socketList);
// somehow have a max file descriptor, set this?
// CODE HERE
// max file descriptor, this will be used to 'find' the socket currently connected
int maxFD = socketEchoFD;
// while loop that will continue to listen for messages from clients.
printf("Echoserver listening on port: %d\n", ECHOPORT);
@ -69,10 +65,8 @@ int main(int argc, char **argv)
// somehow use the set of file descriptor sockets here
// CODE HERE
// use the select() function here to check the set of sockets
// CODE HERE
int selectedFD = select(maxFD+1, &socketList, NULL, NULL, NULL);
// check to make sure select() didn't error out.
// CODE HERE
if(selectedFD == -1)
{
//