How to test a TCP/IP connection to a remote host (www.google.com) on a given port (80):
$ nc -v -w 1 -z www.google.com 80
Connection to www.google.com 80 port [tcp/http] succeeded!
How to test a UDP/IP connection to a remote host (18.104.22.168) on a given port (4672):
$ nc -u -v -w 1 -z 22.214.171.124 4672
Connection to 126.96.36.199 4672 port [udp/rfa] succeeded!