Recently, I downloaded NETCAT on my MAC (OSX El Capitan 10.11.5) via MacPorts (2.3.4).
I created a simple TCP server with:
nc -v -l -p 3456
When I tried to connect to the server via:
nc -v localhost -p 3456
I would receive a connection open message but the connection would terminate after the client connects. I thought the connection would stay open until I hit CTRL-C or entered ^D.
Do I add a time wait for keeping the connection open on a MAC?
BTW, a friend tried the same commands on a Linux box and it worked as expected.
There are different implementations of nc
(netcat), which support different options and have to be used accordingly. Your example would not work with the netcat provided by the Mac operating system in /usr/bin/nc
.
If the nc
on Linux behaves differently, you should check the man page on both systems to confirm the flags and options you used are actually for the purpose you intended.