freeport v0.1.0

Get a TCP port that is ready to use

freeport

Get a free and open TCP port that is ready to use. Inspired by FreePort.

GitHub release Travis

Installation

Command Line

Download the executable from the release page or build from source with shards build.

Library

Add this to your application's shard.yml:

dependencies:
  freeport:
    github: petoem/freeport
    version: 0.1.0

Usage

Command Line

> freeport -h
Usage: freeport [arguments]
    -n, --newline                    Print port number with a newline
    -v, --version                    Output version information and exit
    -h, --help                       Show this help

Library

require "freeport"

# Returns a free TCP port, may raise an exception if no free ports are available.
FreePort.get

# Returns a free TCP port or `nil`.
FreePort.get?

Limitation

freeport returns a port available at the moment, a race condition may occur and the port could be taken by the time you try binding to the port yourself.

Contributing

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

freeport

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • almost 6 years ago
  • January 27, 2019
License

MIT License

Links
Synced at

Thu, 26 Dec 2024 12:37:34 GMT

Languages