nettest

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

Nettest

This package provides a simple way to get an open TCP/UDP port that can then be used for testing.

Example Usage

port := nettest.GetTCP()

address := net.JoinHostPort("0.0.0.0", strconv.Itoa(port))

listener, err := net.Listen("tcp", address)
if err != nil {
    return err
}

rpc.Accept(listener)

Documentation

Overview

Package nettest please refer to README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTCP

func GetTCP() int

GetTCP returns a TCP port that is available for use.

NOTE: in the very rare case when no ports are available, this method will panic

func GetUDP

func GetUDP() int

GetUDP returns a UDP port that is available for use.

NOTE: in the very rare case when no ports are available, this method will panic

Types

This section is empty.

Jump to

Keyboard shortcuts

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