With the -z option, netcat will attempt to connect to all TCP ports on the targets in a sequential fashion (if no ports are specified; otherwise just to the specified port), reporting which are open. It’s like a simple, very slow version of Nmap!

Use -w to set the timeout in seconds.

Use -u to try connecting over UDP rather than TCP.