source: npl/overig/netcat_openbsd/patches/0010-serialized-handling-multiple-clients.patch @ 128fde4

gcc484perl-5.22
Last change on this file since 128fde4 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.6 KB
  • netcat.c

    From: Aron Xu <aron@debian.org>
    Date: Tue, 14 Feb 2012 23:02:00 +0800
    Subject: serialized handling multiple clients
    
    ---
     netcat.c |   39 +++++++++++++++++++--------------------
     1 file changed, 19 insertions(+), 20 deletions(-)
    
    diff --git a/netcat.c b/netcat.c
    index 56cc15e..bf9940f 100644
    a b main(int argc, char *argv[]) 
    447447                                s = unix_bind(host);
    448448                        else
    449449                                s = unix_listen(host);
    450                 }
     450                } else
     451                        s = local_listen(host, uport, hints);
     452                if (s < 0)
     453                        err(1, NULL);
     454
     455                char* local;
     456                if (family == AF_INET6)
     457                        local = ":::";
     458                else
     459                        local = "0.0.0.0";
     460                fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
     461                        host ?: local,
     462                        family,
     463                        *uport);
    451464
    452465                /* Allow only one connection at a time, but stay alive. */
    453466                for (;;) {
    454                         if (family != AF_UNIX)
    455                                 s = local_listen(host, uport, hints);
    456                         if (s < 0)
    457                                 err(1, NULL);
    458467
    459                         char* local;
    460                         if (family == AF_INET6 )
    461                                 local = "0.0.0.0";
    462                         else if (family == AF_INET)
    463                                 local = ":::";
    464                         else
    465                                 local = "unknown";
    466                         fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
    467                                 host ?: local,
    468                                 family,
    469                                 *uport);
    470468                        /*
    471469                         * For UDP, we will use recvfrom() initially
    472470                         * to wait for a caller, then use the regular
    main(int argc, char *argv[]) 
    536534                                close(connfd);
    537535                        }
    538536
    539                         if (family != AF_UNIX)
     537                        if (kflag)
     538                                continue;
     539                        if (family != AF_UNIX) {
    540540                                close(s);
     541                        }
    541542                        else if (uflag) {
    542543                                if (connect(s, NULL, 0) < 0)
    543544                                        err(1, "connect");
    544545                        }
    545 
    546                         if (!kflag)
    547                                 break;
     546                        break;
    548547                }
    549548        } else if (family == AF_UNIX) {
    550549                ret = 0;
Note: See TracBrowser for help on using the repository browser.