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

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.2.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.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_portcheck-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cccb443be11608989a9b6fb72d537c121ca0c57309b20e4c42e487f649516075
MD5 5ef8e643e63fdab1795224ebd1f217aa
BLAKE2b-256 aa47272d883aaa8dd8f563617d033240f2336bc35377b3f2215b3d95bb5c3ce5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_portcheck-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1f672bef256755ea3c74a00544966c1a9f4b1b85f98bf3f17bfeaafb480004
MD5 8e13dbbe3409c902c8032f0d68093d8e
BLAKE2b-256 0702902a0d888ea14358b2d64b06f21bd20cedc9c41508f1569b58458e6f5bae

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