port

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	Addr *net.TCPAddr
	// contains filtered or unexported fields
}

Checker is used to check for available ports on a host.

func NewChecker

func NewChecker(host string) (*Checker, error)

NewChecker returns a Checker that can check ports on the given host.

func (*Checker) AvailableRange

func (c *Checker) AvailableRange(size int) (int, int, error)

AvailableRange asks the operating system for ports until it is given a contiguous range of ports size long. It returns the first and last of those port numbers, having released all the ports it took, so they are ready for you to use.

NB: there is the potential for a race condition here, where once released, another process gets one of the ports before you use it, so start listening on all the returned ports as soon as possible after calling this.

Jump to

Keyboard shortcuts

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