Skip to main content

SRE Toolbox

TCP Port Ping

Repeatedly connect to a TCP host and port and report latency.

Requires Python 3.13 or newer. The runtime is the standard library only.

Install

pip install lupaxa-tcp-port-ping
tcp-port-ping --help

CLI

tcp-port-ping --server example.com --port 80
tcp-port-ping -s example.com -p 443 -d 1
tcp-port-ping -s 192.0.2.10 -p 22 --count 5 --timeout 0.5
python -m lupaxa.tcp_port_ping --version

The tool opens a TCP connection, times the handshake, closes it, and repeats after --delay seconds (default 1). --server and --port are required. --timeout bounds the socket (default 1 second). Omit --count to run until Ctrl-C. A successful probe prints Connected to <host>[<port>]: tcp_seq=<n> time=<ms> ms. Timeouts print Connection timed out!. A refused port prints Port is closed!!!. The summary is TCP Ping Results: Connections (Total/Pass/Fail): [T/P/F] (Failed: N%). Ctrl-C prints that summary immediately and exits 0.

Flags

Flag Default Description
--server required Hostname or IP address (-s)
--port required TCP port (1–65535, -p)
--delay 1 Seconds between probes (0 or more, -d)
--count run until interrupted Number of probes (-c)
--timeout 1 Socket timeout in seconds (-T)
--version — Print the package version and exit

--timeout must be greater than 0. --count must be greater than 0 when set.

Exit Codes

Code When
0 Help, version, Ctrl-C, or every --count probe succeeded
1 Invalid arguments, or at least one --count probe failed

Examples

HTTPS:

tcp-port-ping --server example.com --port 443

Five SSH probes, half-second timeout (exit 1 if any fail):

tcp-port-ping -s 192.0.2.10 -p 22 --count 5 --timeout 0.5

Back-to-back local probes (--delay 0 is valid):

tcp-port-ping -s 127.0.0.1 -p 8080 --delay 0 --count 10 --timeout 0.2

Library

from lupaxa.tcp_port_ping import probe_tcp_port, run_probes

one = probe_tcp_port("example.com", 443, timeout=1.0)
print(one.ok, one.elapsed_ms, one.detail)

summary = run_probes("example.com", 443, count=3, delay=0)
print(summary.total, summary.passed, summary.failed, summary.fail_percent)

probe_tcp_port returns a ProbeResult with ok, host, port, sequence, elapsed_ms, and detail. Host whitespace is stripped. detail is a short lowercase reason (connected, connection timed out, port is closed, or OS error: …). The CLI maps those strings to the ping-style wording above. Refused ports, timeouts, and socket errors return ok=False instead of raising.

run_probes returns a ProbeSummary (total, passed, failed, fail_percent, results) and defaults to one probe. Pass count=None to run until should_stop or forever. Invalid host, port, timeout, delay, or count raises ValueError.

Development

make init
make python-install-dev
make python-check
The Lupaxa Project Footer

Metadata

Release files for lupaxa-tcp-port-ping 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lupaxa-tcp-port-ping 0.1.5
File Size Uploaded
lupaxa_tcp_port_ping-0.1.5.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lupaxa-tcp-port-ping 0.1.5
File Interpreter ABI Platform
lupaxa_tcp_port_ping-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / lupaxa_tcp_port_ping-0.1.5.tar.gz

Download URL lupaxa_tcp_port_ping-0.1.5.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
430485aba2b4740bcf907621f1252259167fb7adbfd44ceded47197012341108
BLAKE2b-256 checksum
How to use checksums
11345a0639785e1a45095e7cc3b2ffc88e118a1b0195f33a6e9ed8a00ac58082
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / lupaxa_tcp_port_ping-0.1.5-py3-none-any.whl

Download URL lupaxa_tcp_port_ping-0.1.5-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d0cac20f99933c7e38b0d5c0c5d3f4b6d3217c2b1b3b01bee2cf8d802dd0bdd
BLAKE2b-256 checksum
How to use checksums
a7130f17edd48ea7b9698372373052924f407b03e5b700b481ea57a4ad246602
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page