Skip to main content

Check if a port is open on a host

Project description

philiprehberger-portcheck

Tests PyPI version Last updated

Check if a port is open on a host.

Installation

pip install philiprehberger-portcheck

Usage

from philiprehberger_portcheck import is_open, scan, wait_for

# Single port check
is_open("localhost", 8080)                  # True/False
is_open("192.168.1.1", 22, timeout=2.0)    # True/False

# Scan multiple ports
results = scan("localhost", ports=[80, 443, 8080, 5432])
for port, result in results.items():
    if result.is_open:
        print(f"Port {port}: open ({result.service})")

# Scan common ports
results = scan("localhost", ports="common")

# Wait for a port to become available
wait_for("localhost", 5432, timeout=30)

API

Function / Class Description
is_open(host, port, timeout=2.0) Check if a TCP port is open
scan(host, ports, timeout=1.0, max_workers=50) Scan multiple ports concurrently
wait_for(host, port, timeout=30, interval=1.0) Block until port opens or raise TimeoutError
PortResult Scan result — .port, .is_open, .service
COMMON_PORTS List of well-known port numbers (HTTP, SSH, DB, etc.)

Development

pip install -e .
python -m pytest tests/ -v

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_portcheck-0.1.8.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_portcheck-0.1.8-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_portcheck-0.1.8.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_portcheck-0.1.8.tar.gz
Algorithm Hash digest
SHA256 870fb262ba370513a4b8c73860d5d4f8a9c72630a97879a6181706f1a5726829
MD5 0ba05f6c3de2fa71004a31dacc87443b
BLAKE2b-256 f4abd9df3977cb2a71082e7227d909e58a17c045c0ea795cc6daea8fbcc0b420

See more details on using hashes here.

File details

Details for the file philiprehberger_portcheck-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_portcheck-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4bea4257464d2308b1715dd02c18ee86088a8c6fcbf528967243643d81e3ffeb
MD5 a4e33ac4166bdb768218296161d1f400
BLAKE2b-256 61edc1584d69c6df13a9563ca0a0848107a010b62eb6e6ee8cd26c8af594bc09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page