clean up the code, remove some of the 'CODE HERE' comments. retesting now.
This commit is contained in:
parent
b31492b988
commit
da93ce1541
1 changed files with 1 additions and 7 deletions
|
|
@ -48,19 +48,15 @@ int main(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// use fnctl to set the non-blocking flag for the socket
|
// use fnctl to set the non-blocking flag for the socket
|
||||||
// CODE HERE
|
|
||||||
fcntl(socketEchoFD, F_SETFL, O_NONBLOCK);
|
fcntl(socketEchoFD, F_SETFL, O_NONBLOCK);
|
||||||
// the server will now accept client connections by listening.
|
// the server will now accept client connections by listening.
|
||||||
listen(socketEchoFD, MAX_CONNECT_QUEUE);
|
listen(socketEchoFD, MAX_CONNECT_QUEUE);
|
||||||
// create a file descriptor set, to keep track of the sockets in use using fd_set and FD_ZERO?
|
// 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_set socketList;
|
||||||
FD_ZERO(&socketList);
|
FD_ZERO(&socketList);
|
||||||
// add the socketEchoFD to the file descriptor set using fd_set
|
// add the socketEchoFD to the file descriptor set using fd_set
|
||||||
// CODE HERE
|
|
||||||
FD_SET(socketEchoFD, &socketList);
|
FD_SET(socketEchoFD, &socketList);
|
||||||
// somehow have a max file descriptor, set this?
|
// max file descriptor, this will be used to 'find' the socket currently connected
|
||||||
// CODE HERE
|
|
||||||
int maxFD = socketEchoFD;
|
int maxFD = socketEchoFD;
|
||||||
// while loop that will continue to listen for messages from clients.
|
// while loop that will continue to listen for messages from clients.
|
||||||
printf("Echoserver listening on port: %d\n", ECHOPORT);
|
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
|
// somehow use the set of file descriptor sockets here
|
||||||
// CODE HERE
|
// CODE HERE
|
||||||
// use the select() function here to check the set of sockets
|
// use the select() function here to check the set of sockets
|
||||||
// CODE HERE
|
|
||||||
int selectedFD = select(maxFD+1, &socketList, NULL, NULL, NULL);
|
int selectedFD = select(maxFD+1, &socketList, NULL, NULL, NULL);
|
||||||
// check to make sure select() didn't error out.
|
// check to make sure select() didn't error out.
|
||||||
// CODE HERE
|
|
||||||
if(selectedFD == -1)
|
if(selectedFD == -1)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue