Skip to content

About

🎃Check TCP port reachability on one IPv4 host with zero runtime dependencies

Topics

Resources

Contributing

Stars

23 stars

Watchers

1 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

pyportscanner

CI status Latest PyPI version Python 3.11 and newer Apache-2.0 license

Check TCP port reachability on a single IPv4 host using only the Python standard library.

API reference · Changelog · Releases

Installation

python -m pip install "pyportscanner>=0.4.0"

From a local checkout, run python -m pip install . in the repository root.

Quickstart

Check a local service on port 8000.

from pyportscanner import PortScanner

scanner = PortScanner(target_ports=[8000], timeout=0.5)
print(scanner.scan("127.0.0.1"))
{8000: 'OPEN'}

The example output assumes a service is listening. The result uses "CLOSE" when a connection fails, including when it times out. To try it with a listener that the example starts for you, run python examples/PortScanExample.py from an installed checkout.

Port selection

Input Ports checked
target_ports=[8000, 8443] The listed ports
target_ports=3 The first three ports in the built-in priority list
target_ports=None All 24 built-in ports

The legacy import from pyportscanner import pyscanner still works. Version 0.4 replaces the bundled Nmap service database with the built-in list. Pass explicit ports to keep the same targets across versions.

Contributing

See the contribution guide for local setup, tests, and reporting bugs.

Build distributions

python -m pip install build twine
python -m build
python -m twine check --strict dist/*

The build writes a wheel and source distribution to dist/.

License

Apache-2.0. See the license text.

About

🎃Check TCP port reachability on one IPv4 host with zero runtime dependencies

Topics

Resources

Contributing

Stars

23 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages