title: Alternative in CentOS 7 for "nc -z"
body: <p>I have a bash program that checks that a daemon in a given port is working:</p>
  
  <pre><code>nc -z localhost $port &gt; /dev/null
  if [ "$?" != "0" ]
  then
    echo The server on port $port is not working
    exit
  fi
  </code></pre>
  
  <p>This program works perfectly in CentOS 6. However, it seems that CentOS 7 has changed the underlying implementation for <code>nc</code> command (CentOS 6 seems to use Netcat and CentOS 7 uses another thing called Ncat) and now the <code>-z</code> switch doesn't work:</p>
  
  <pre><code>$ nc -z localhost 8080
  nc: invalid option -- 'z'
  </code></pre>
  
  <p>Looking to the <code>man nc</code> page in CentOS 7 I don't see any clear alternative to <code>-z</code>. Any suggestion on how I should fix my bash program to make it work in CentOS 7?</p>