freeport

package module
v0.0.0-...-32cc5b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2019 License: BSD-3-Clause Imports: 2 Imported by: 1

README

FreePort

Get a free open TCP or UDP port that is ready to use

# Ask the kernel to give us an open port.
export port=$(freeport TCP)

# Start standalone httpd server for testing
httpd -X -c "Listen $port" &

# Curl local server on the selected port
curl localhost:$port
usage
sudo apt-get install golang                    # Download go. Alternativly build from source: https://golang.org/doc/install/source
mkdir ~/.gopath && export GOPATH=~/.gopath     # Replace with desired GOPATH
export PATH=$PATH:$GOPATH/bin                  # For convenience, add go's bin dir to your PATH
go get github.com/iain17/freeport/cmd/freeport

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPortRange

func GetPortRange(netType string, numRange int) int

Get an open TCP port that has ports free going upwards. returns a int of the open port. You can safely say that all the ports above it till numRange are also free

func GetTCPPort

func GetTCPPort() int

Get an open TCP port. returns a int of the open port.

func GetUDPPort

func GetUDPPort() int

Get an open UDP port. returns a int of the open port.

func IsFree

func IsFree(netType string, port int) bool

func IsFreeTCP

func IsFreeTCP(port int) bool

func IsFreeUDP

func IsFreeUDP(port int) bool

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL