Ncat/EOF behavior
From SecWiki
< Ncat
This page describes how Ncat handles End Of File when reading from various places. We wish to be consistent internally and to be consistent with Traditional and OpenBSD netcats when they agree with each other.
Contents
Behavior
Client/Connect Mode (TCP)
EOF on: | stdin | socket |
---|---|---|
no options | closes socket write[1], keeps running | closes stdout, quits[2] |
--send-only | quits | N/A, does not read from socket |
--recv-only | N/A, does not read from stdin | quits |
Server/Listen mode (TCP)
EOF on: | stdin | socket |
---|---|---|
no options | closes socket write[1], keeps running | closes stdout, quits |
--send-only | quits | N/A, does not read from socket |
--recv-only | N/A, does not read from stdin | quits |
Other considerations
--no-shutdown
Ncat supports the TCP idea of half-open connections. When EOF is read on stdin, Ncat calls shutdown
on the socket in the "write" direction. The --no-shutdown
option can be used to prevent this behavior, and may be necessary in some circumstances in order to prevent Ncat from closing entirely while there is still data to be received.
--keep-open
The --keep-open
or -k
option can be used in server mode to run a simple forking network server. In this case, the tables above may not describe the behavior of the forked processes.