Metadata-Version: 2.4
Name: philiprehberger-portcheck
Version: 0.1.3
Summary: Check if a port is open on a host
Project-URL: Homepage, https://github.com/philiprehberger/py-portcheck#readme
Project-URL: Repository, https://github.com/philiprehberger/py-portcheck
Project-URL: Issues, https://github.com/philiprehberger/py-portcheck/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-portcheck/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: check,network,port,scan,socket,tcp
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# philiprehberger-portcheck

[![Tests](https://github.com/philiprehberger/py-portcheck/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-portcheck/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-portcheck.svg)](https://pypi.org/project/philiprehberger-portcheck/)
[![License](https://img.shields.io/github/license/philiprehberger/py-portcheck)](LICENSE)

Check if a port is open on a host.

## Installation

```bash
pip install philiprehberger-portcheck
```

## Usage

```python
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
