Skip to main content

Check if a port is open on a host

Project description

philiprehberger-portcheck

Tests PyPI version License

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

  • is_open(host, port, timeout=2.0) — Check if 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

Development

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

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.4.tar.gz (4.6 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.4-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_portcheck-0.1.4.tar.gz
Algorithm Hash digest
SHA256 611cd1b2dba8c858d83ade1bf0683952ddf90fc70276738f44ede9799cea088e
MD5 3f35c004799b1aad4cad162e5c06d002
BLAKE2b-256 6e30e34731dcd59c10607fb1ab4ce5bbdda6e4d76deb20eeb2442307fd452949

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_portcheck-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 29054ca8c6a87ed1479f806ce36269216a80f20d8ed5dbbf0375cfd12297265c
MD5 f2058e88a179c99dcdc142b10907cc0c
BLAKE2b-256 62ce3d54bc021d573f387ac0b0d5d47a44749f0253efd1964afa4a421ad5cbfd

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