From 91fad2cdaa17477a38a3878a78a4bffad9dc4d51 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 21 Oct 2022 03:36:26 -0500 Subject: [PATCH] Fix netcat -u server mode. Tested with "netcat -s 127.0.0.1 -p 9876 -l" talking to "netcat 127.0.0.1 9876" and yes, they can type at each other. --- toys/net/netcat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/net/netcat.c b/toys/net/netcat.c index 74eb94a9..7c4fdefe 100644 --- a/toys/net/netcat.c +++ b/toys/net/netcat.c @@ -125,7 +125,7 @@ void netcat_main(void) sockfd = xbindany(xgetaddrinfo(TT.s, toybuf, family, type, 0, 0)); } - if (listen(sockfd, 5)) error_exit("listen"); + if (!FLAG(u) && listen(sockfd, 5)) perror_exit("listen"); if (!TT.p && !FLAG(U)) { struct sockaddr* address = (void*)toybuf; socklen_t len = sizeof(struct sockaddr_storage); -- 2.39.2