netcat not stopping when program ends
I use the following command to setup netcat to read + write from a program from the command line:
./program < IN | nc -k -l 9001 >IN
Basically I have a fifo IN and take my inputs from it, and pipe the output to nc which pushes incoming commands to the IN fifo. -k to allow another connection if the user disconnects.
However, when the program ends and returns this command doesn't always end (and return to the command line). If I try to connect to the port again it seems to accept the connection but then close it immediately; however, my knowledge of how TCP connections are made and closed is low so I could be mistaking its behavior. A couple times it the program did end and return to the command line. I wonder if it has something to do with the other ends connection?
|