Permalink
Browse files

Check return value of select for error

  • Loading branch information...
1 parent bef021a commit 3aacef9d2f0333428a5db61fb310f2cc2793d8d0 @rosslagerwall committed Sep 5, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 examples_01/01_rot13_server_select.c
@@ -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;
@@ -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;

0 comments on commit 3aacef9

Please sign in to comment.