summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Jackson <ericj@cvs.openbsd.org>2001-06-26 23:06:54 +0000
committerEric Jackson <ericj@cvs.openbsd.org>2001-06-26 23:06:54 +0000
commit00192d9f76bd24caf45bff8fe012552198182daa (patch)
tree4407c742d2b81bbfa1aef5bcdefeb08508fdf864
parent1cfb3f5ce187b492cffd8a26bff34c7d29899bed (diff)
allow -k for udp and tcp
-rw-r--r--usr.bin/nc/netcat.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index 70d98da2b1e..36bb0f5e8ca 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.26 2001/06/26 21:57:35 ericj Exp $ */
+/* $OpenBSD: netcat.c,v 1.27 2001/06/26 23:06:53 ericj Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@@ -174,13 +174,12 @@ main(argc, argv)
if (lflag) {
int connfd;
-
- if ((s = local_listen(host, uport, hints)) < 0)
- errx(1, NULL);
-
ret = 0;
+
/* Allow only one connection at a time, but stay alive */
for (;;) {
+ if ((s = local_listen(host, uport, hints)) < 0)
+ errx(1, NULL);
/*
* For UDP, we will use recvfrom() initially
* to wait for a caller, then use the regular
@@ -211,6 +210,8 @@ main(argc, argv)
readwrite(connfd);
close(connfd);
+ close(s);
+
if (!kflag)
break;
}