Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Aug 18 '11 at 13:29

This question came from our site for professional and enthusiast programmers.

2  
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 May 14 '11 at 22:08
1  
Try ncat (in the nmap distro). –  William Pursell May 14 '11 at 23:38
1  
Try socat, completely different syntax, but way more capabilities than the good old netcat's. –  Marcin Aug 18 '11 at 14:43
    
@icktoofay if you move you're comment to answers i'll upvote then vote to close ... just tag me in the post so i see it –  hbdgaf Oct 22 '11 at 1:12

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.