Skip to main content

Generate a free TCP or UDP random port

Project description

Random Port

Introduction

Usually we need start a TCP or UDP server (mainly to use in tests) but, which port must be used? So, random-port is the answer. It generate a free random TCP or UDP port to be used for any server.

How to install

Install it using pip command:

pip install random-port

in your project folder.

Usage

  • To a TCP random port:
port = RandomTcpPort().value()
  • To a UDP random port:
port = RandomUdpPort().value()

License

The MIT License (MIT)

Copyright (C) 2025 Fabrício Barros Cabral

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

random_port-0.0.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

random_port-0.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file random_port-0.0.2.tar.gz.

File metadata

  • Download URL: random_port-0.0.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for random_port-0.0.2.tar.gz
Algorithm Hash digest
SHA256 cc250e9b9ebb1071c7db6e3d7cfb534354a1b7e2e6276e46c6f323767726c18f
MD5 674045924aa0fdbea472c9ead325906f
BLAKE2b-256 afad84aec9149b5453276183923c56a5db47c5bd99694f34eccddfff3bfbcd41

See more details on using hashes here.

File details

Details for the file random_port-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: random_port-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for random_port-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e2fbde44b15217f2e1ac236004f3d906969888e5787091321dee721dd1b936c
MD5 7b5be1f32b2cf7f22cca9429317f1984
BLAKE2b-256 c463b5fd30be66147b468550ba8022e927a6ea329c4ee225a4e82a2d6f107783

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