title: nc (netcat) on Mac OS X 10.8.4 gets stuck
body: <p>I encountered a little issue while using the nc utility on Mac OS X, a utility i often use as a quick and dirty solution to check if a port is open and what version the daemon is running.</p>
  
  <p>We deployed a new set of computers the other day and i wanted to verify what version of sshd they were running, without having to leave my chair.</p>
  
  <p>This is the command i ran and the resulting output:</p>
  
  <pre><code>$ for i in {183..200}; do echo "hello" | nc -n -w 2 -v 10.120.113.$i 22; done
  Connection to 10.120.113.183 22 port [tcp/*] succeeded!
  SSH-2.0-OpenSSH_5.9
  Protocol mismatch.
  nc: connect to 10.120.113.184 port 22 (tcp) failed: Connection refused
  ^C
  $
  </code></pre>
  
  <p>It finds the first machine on 183 and returns the daemon version, it dont look like the sshd is running on 184, but when it hits 185 it simply stops and i have to kill it with ctrl+c.</p>
  
  <p>As i have understood the man page for nc it should time out when using the '-w' switch, but it don't. Its the same issue from multiple machines.</p>
  
  <p>Is this simply the case of me misunderstanding the man page?
  Is there any other way to make nc time out after X seconds if don´t receive any response?
  Is there any other way to do this using the builtin tools in Mac OS X?</p>
  
  <p>I´ve also tried running nc with only the '-z' switch with the same results.
  The machines are placed in our production so i´m not allowed to install any 3rd party applications like nmap.</p>
  
  <pre><code>Platform: Mac OS X 10.8.4
  Executable: /usr/bin/nc
  </code></pre>
  
  <p>Sorry if this question has been answered, i searched but could not find any solution to this.</p>