title: Efficiently test if a port is open on Linux?
body: <p>From a bash script how can I quickly find out whether a port <code>445</code> is open/listening on a server.</p>
  
  <p>I have tried a couple of options, but I want something quick:<br>
  1. <code>lsof -i :445</code>  (Takes seconds)<br>
  2. <code>netstat -an |grep 445 |grep LISTEN</code> (Takes seconds)<br>
  3. <code>telnet</code> (it doesn't return)<br>
  4. <code>nmap</code>, <code>netcat</code> are not available on the server  </p>
  
  <p>It will be nice to know of a way that doesn't enumerate first and greps after that.</p>