in reply to TCP port test
The simplest way would likely to connect to the socket, or to use a IO::Socket to connect to it.
Otherwise, Net::Ping can also check whether a port is reachable.