(main): Remove local STATUS. Remember result of accept and add that
authorroland <roland>
Mon, 14 Feb 1994 03:19:45 +0000 (03:19 +0000)
committerroland <roland>
Mon, 14 Feb 1994 03:19:45 +0000 (03:19 +0000)
(rather than the uninitialized variable STATUS) to ACTIVE_FD_SET.

manual/examples/inetsrv.c

index 12619b4..5bc19fe 100644 (file)
@@ -39,7 +39,6 @@ main (void)
 {
   extern int make_socket (unsigned short int port);
   int sock;
-  int status;
   fd_set active_fd_set, read_fd_set;
   int i;
   struct sockaddr_in clientname;
@@ -74,9 +73,10 @@ main (void)
            if (i == sock)
              {
                /* Connection request on original socket. */
+               int new;
                size = sizeof (clientname);
-               if (accept (sock,
-                           (struct sockaddr *) &clientname, &size) < 0)
+               new = accept (sock, (struct sockaddr *) &clientname, &size);
+               if (new < 0)
                  {
                    perror ("accept");
                    exit (EXIT_FAILURE);
@@ -85,7 +85,7 @@ main (void)
                         "Server: connect from host %s, port %hd.\n",
                         inet_ntoa (clientname.sin_addr),
                         ntohs (clientname.sin_port));
-               FD_SET (status, &active_fd_set);
+               FD_SET (new, &active_fd_set);
              }
            else
              {