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:
parent
eb996e5650
commit
8a19fe36e1
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user