diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c index 1277ba278..052b6f191 100644 --- a/ncat/ncat_connect.c +++ b/ncat/ncat_connect.c @@ -786,8 +786,8 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data) if (status == NSE_STATUS_EOF) { shutdown(nsi_getsd(cs.sock_nsi), SHUT_WR); - /* In --send-only mode, exit after EOF on stdin. */ - if (o.sendonly) + /* In --send-only mode or non-TCP mode, exit after EOF on stdin. */ + if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly)) nsock_loop_quit(nsp); return; } else if (status == NSE_STATUS_ERROR) { @@ -833,8 +833,8 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data) if (status == NSE_STATUS_EOF) { Close(STDOUT_FILENO); - /* In --recv-only mode, exit after EOF on the socket. */ - if (o.recvonly) + /* In --recv-only mode or non-TCP mode, exit after EOF on the socket. */ + if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.recvonly)) nsock_loop_quit(nsp); return; } else if (status == NSE_STATUS_ERROR) { diff --git a/ncat/ncat_listen.c b/ncat/ncat_listen.c index 1631e44ac..ce26587a7 100644 --- a/ncat/ncat_listen.c +++ b/ncat/ncat_listen.c @@ -331,7 +331,7 @@ static int ncat_listen_stream(int proto) /* Read from stdin and write to all clients. */ rc = read_stdin(); if (rc == 0) { - if (o.sendonly) { + if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly)) { /* There will be nothing more to send. If we're not receiving anything, we can quit here. */ return 0;