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 or fixed TCP/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 use a TCP random port:
from random_port.pool import TcpRandomPort

port = TcpRandomPort().value()
  • To use a random UDP port:
from random_port.pool import UdpRandomPort

port = UdpRandomPort().value()
  • To use a fixed TCP port:
from random_port.pool import TcpPort

port = TcpPort(12345).value()
  • To use a fixed UDP port:
from random_port.pool import UdpPort

port = UdpPort(12345).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.9.tar.gz (3.3 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.9-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: random_port-0.0.9.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.9

File hashes

Hashes for random_port-0.0.9.tar.gz
Algorithm Hash digest
SHA256 bc317b8789a69fb71b6037b7bb399560f060df42462e3f2f6630c79b152e5cc2
MD5 28abb6e8de566d4fd1f335d55781d047
BLAKE2b-256 4eab20982d60247e42d84b077e3b7271a344d26f0a65ab4dea171dafad766685

See more details on using hashes here.

Provenance

The following attestation bundles were made for random_port-0.0.9.tar.gz:

Publisher: python-release.yml on fabriciofx/random-port

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: random_port-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.9

File hashes

Hashes for random_port-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 0f0ad971673e99fe19acece2b0a021df565515ef110a890e2c2becda565d0687
MD5 d87cbd3c5ffd735bfab230b9f1d11643
BLAKE2b-256 0a3f9d22409c6b20e8af69708675ff86eb119dae3ff35101ef3f4ecb4ca4db03

See more details on using hashes here.

Provenance

The following attestation bundles were made for random_port-0.0.9-py3-none-any.whl:

Publisher: python-release.yml on fabriciofx/random-port

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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