Skip to content

Commit

Permalink
Check return value of select for error
Browse files Browse the repository at this point in the history
  • Loading branch information
rosslagerwall committed Sep 5, 2012
1 parent bef021a commit 3aacef9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples_01/01_rot13_server_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ run(void)
int listener;
struct fd_state *state[FD_SETSIZE];
struct sockaddr_in sin;
int i, n, maxfd;
int i, maxfd;
fd_set readset, writeset, exset;

sin.sin_family = AF_INET;
Expand Down Expand Up @@ -177,7 +177,10 @@ run(void)
}
}

n = select(maxfd+1, &readset, &writeset, &exset, NULL);
if (select(maxfd+1, &readset, &writeset, &exset, NULL) < 0) {
perror("select");
return;
}

if (FD_ISSET(listener, &readset)) {
struct sockaddr_storage ss;
Expand Down

0 comments on commit 3aacef9

Please sign in to comment.