Upgrading telnet client to new TCP code
authorJohn Hodge <[email protected]>
Wed, 2 Mar 2011 06:09:46 +0000 (14:09 +0800)
committerJohn Hodge <[email protected]>
Wed, 2 Mar 2011 06:09:46 +0000 (14:09 +0800)
Usermode/Applications/telnet_src/main.c

index 6c4f892..f4f048a 100644 (file)
@@ -27,14 +27,15 @@ int main(int argc, char *argv[], char *envp[])
        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
@@ -57,6 +58,11 @@ int main(int argc, char *argv[], char *envp[])
                                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

UCC git Repository :: git.ucc.asn.au