netcat_server: do not loop forever

To make it similar to other implementations.
(I followed the behavior of NetBSD's nc, which came from OpenBSD.)
This commit is contained in:
YAMAMOTO Takashi 2021-01-28 12:52:05 +09:00 committed by Xiang Xiao
parent eb996e5650
commit 8a19fe36e1

View File

@ -133,13 +133,9 @@ int netcat_server(int argc, char * argv[])
socklen_t addrlen; socklen_t addrlen;
int conn; int conn;
while ((conn = accept(id, (struct sockaddr *)&client, &addrlen)) != -1) if ((conn = accept(id, (struct sockaddr *)&client, &addrlen)) != -1)
{ {
result = do_io(conn, outfd); result = do_io(conn, outfd);
if (result != 0)
{
break;
}
} }
if (0 > conn) if (0 > conn)