I've tried the two main versions of netcat : GNU and BSD. (mine is BSD Version).

On GNU version, the command $ nc -l -p 12345 works fine but with BSD, option -l (listen) can't be used in conjonction with -p (local port).

I don't understand why there is a such difference between these two versions ? In the BSD version, when I use option -p, it calls automatically -l (listen) ?

thanks ;-)

Ps: https://bugs.launchpad.net/ubuntu/+source/netcat-openbsd/+bug/590925/comments/3 -p is different between the two. The OpenBSD version uses it to set a source port for remote connections, while the traditional nc uses it to specify the local port on which it will listen when in listen mode.


In the BSD version, -l takes the port to listen on, so -p is not needed at all. I'm not sure what -p does without -l. I don't know why there's a difference. – icktoofay <--credit for the solution goes to that guy...but I don't think he has an account on SU, just SO.