Skip to main content

A Python implementation of TCP ping that tests connectivity to a remote host

Project description

tcpp

A Python implementation of TCP ping that tests connectivity to a remote host by attempting TCP connections. It measures connection establishment times and provides detailed statistics.

Features

  • 🚀 Pure Python implementation, no external dependencies
  • 📦 Lightweight and easy to use
  • 🌐 Supports both IPv4 and IPv6
  • 🔄 Supports continuous ping mode

Installation

You can install tcpp directly from PyPI:

pip install tcpp

Usage

Command Line

Basic usage:

tcpp bing.com

With custom port and count:

tcpp bing.com 443 -c 10

All available options:

tcpp [-h] [-c COUNT] [-t TIMEOUT] [-4] [-6] [-v] host [port]

positional arguments:
  host                  Target hostname or IP address to ping
  port                  Target port number (default: 80)

options:
  -h, --help           Show this help message and exit
  -c, --count COUNT    Number of pings to send (default: 10, 0 = infinite)
  -t, --timeout SEC    Connection timeout in seconds (default: 1.0)
  -4                   Force using IPv4
  -6                   Force using IPv6
  -v, --version        Show program version

Python API

You can also use tcpp as a Python library:

import tcpp

# Basic usage
stats = tcpp.ping("bing.com", port=80)

# Access statistics
print(f"Success rate: {stats.success_rate}%")
print(f"Average time: {stats.avg_time:.2f}ms")

bing Output

TCPING bing.com (13.107.21.200)[:80]
Connected to bing.com[:80]: seq=1 time=61.64 ms
Connected to bing.com[:80]: seq=2 time=61.39 ms
Connected to bing.com[:80]: seq=3 time=59.84 ms
Connected to bing.com[:80]: seq=4 time=59.29 ms

--- bing.com[:80] tcping statistics ---
4 connections, 4 successed, 0 failed, 100.00% success rate
min = 59.29ms, max = 61.64ms, avg = 60.54ms, med = 60.62ms, mdev = 1.00ms

Requirements

  • Python 3.7 or higher
  • No external dependencies

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

tcpp-1.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

tcpp-1.0.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file tcpp-1.0.1.tar.gz.

File metadata

  • Download URL: tcpp-1.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for tcpp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 856a66e64a1a79a0bf855ff6569513b9ca2fd6847b0f90439a24d94de96435ea
MD5 a244807b2b12433de5b8677fad9dc8e5
BLAKE2b-256 4c8e7a6f9c6e0311177bf68521ac2f0728bba8767e36225c4100cc49e4bd3d01

See more details on using hashes here.

File details

Details for the file tcpp-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tcpp-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for tcpp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cae4ebdc13218c84f0247f0e90720c48944230889228523241634f726727226d
MD5 582fd156722b24f722a3f6491f01fe39
BLAKE2b-256 70a8e4176e0c2ac85a028706c956d486b10a913f21d63361c3c479fdecca6625

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