TCP port monitoring and discovery
Project description
por·tend pôrˈtend/ verb
be a sign or warning that (something, especially something momentous or calamitous) is likely to happen.
Usage
Use portend to monitor TCP ports for bound or unbound states.
For example, to wait for a port to be occupied, timing out after 3 seconds:
portend.occupied('www.google.com', 80, timeout=3)
Or to wait for a port to be free, timing out after 5 seconds:
portend.free('::1', 80, timeout=5)
The portend may also be executed directly. If the function succeeds, it returns nothing and exits with a status of 0. If it fails, it prints a message and exits with a status of 1. For example:
python -m portend localhost:31923 free (exits immediately) python -m portend -t 1 localhost:31923 occupied (one second passes) Port 31923 not bound on localhost.
Portend also exposes a find_available_local_port for identifying a suitable port for binding locally:
port = portend.find_available_local_port() print(port, "is available for binding")
Portend additionally exposes the lower-level port checking functionality in the Checker class, which currently exposes only one public method, assert_free:
portend.Checker().assert_free('localhost', 31923)
If assert_free is passed a host/port combination that is occupied by a bound listener (i.e. a TCP connection is established to that host/port), assert_free will raise a PortNotFree exception.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file portend-3.2.0.tar.gz
.
File metadata
- Download URL: portend-3.2.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5250a352c19c959d767cac878b829d93e5dc7625a5143399a2a00dc6628ffb72 |
|
MD5 | 0c3a2e8073c384b826f87795766f1e0e |
|
BLAKE2b-256 | 8ffcbcfc768996b438d6e4bde7a6c8cfd62089847b0f5381a0e0ec2d8ee6b202 |
File details
Details for the file portend-3.2.0-py3-none-any.whl
.
File metadata
- Download URL: portend-3.2.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b3fe3f78779df906559a21d9eaa6e21c8fa5a7a8cc76362cbbe1e16777399cf |
|
MD5 | 572c2bfe4202140d6df072d457ad2a34 |
|
BLAKE2b-256 | a3c57041b39bcad182a37ec6ea92e7e478a460db6277c542e6d417e34246bdac |