while( client_running )\r
{\r
fd_set fds;\r
+ fd_set err_fds;\r
char buffer[BUFSIZ];\r
int len;\r
\r
- FD_ZERO(&fds);\r
- FD_SET(0, &fds);\r
- FD_SET(server_fd, &fds);\r
+ FD_ZERO(&fds); FD_ZERO(&err_fds);\r
+ FD_SET(0, &fds); FD_SET(0, &err_fds);\r
+ FD_SET(server_fd, &fds); FD_SET(server_fd, &err_fds);\r
\r
- rv = select(server_fd+1, &fds, NULL, NULL, NULL);\r
+ rv = select(server_fd+1, &fds, NULL, &err_fds, NULL);\r
if( rv < 0 ) break;\r
\r
if( FD_ISSET(server_fd, &fds) )\r
write(1, len, buffer);\r
} while( len == BUFSIZ );\r
}\r
+ \r
+ if( FD_ISSET(server_fd, &err_fds) )\r
+ {\r
+ break ;\r
+ }\r
}\r
\r
close(server_fd);\r