My goal is to create a simple echo server using
nc and a single
fifo. I'm not looking for the best way to do it, I'm merely trying to understand the semantics of the following commands (when does fork happen, why, what does it change, why the commands behave differently...).
I'm using Bash, so I'm not sure if all of the commands will work with a POSIX
Here are the four commands I'm mentioning in the title (assuming that I already did
cat fifo | nc -l localhost 8888 > fifo exec 3<> fifo && nc -l localhost 8888 <&3 >&3 && exec 3>&- nc -l localhost 8888 <(cat fifo) > fifo nc -l localhost 8888 < fifo > fifo
Now I would expect the 4 commands to do the same thing, at the very least the two last ones to do the same thing.
- The first command behaves as expected, a simple echo server that shuts down when the client closes the connection.
- Behaves like 1.
- I can connect to the server, send data, but I never receive anything back. When I close the client connection, the server shuts down.
- Can't connect to the server, the server listens forever.