Using Python to check if remote port is open and accessible.
Taken from http://snipplr.com/view/19639/test-if-an-ipport-is-open/
Usage:
- Open a Python prompt
- Run the script in is_port_open.py
- Call isOpen with a host and a port parameter. Example: isOpen("www.google.com", 80)
Small note, this can be sped up by using
connect_ex
instead ofconnect
. The first call will not raise any exceptions (except forNo host found
, but that's standard) and is faster than the second one. Example: