nettest

package
v3.3.54 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FreeTCPPort

func FreeTCPPort() uint16

FreeTCPPort returns a TCP port that is free on "localhost", or panics if it cannot find a port

func TCPPort

func TCPPort(l NetworkListener) uint16

TCPPort of the listener address. If the listener isn't TCP, this may panic()

Types

type NetworkListener

type NetworkListener interface {
	Addr() net.Addr
}

A NetworkListener is a listener that looks for data on a network address. It is sometimes useful in testing to get this address so you can talk to it directly.

type TrackingDialer

type TrackingDialer struct {
	Dialer net.Dialer
	Conns  []net.Conn
}

TrackingDialer remembers connections it's made and allows users to close them

func (*TrackingDialer) Close

func (t *TrackingDialer) Close() error

Close all stored connections. Returns an error on the first close that fails

func (*TrackingDialer) DialTimeout

func (t *TrackingDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

DialTimeout simulates net.DialTimeout

Jump to

Keyboard shortcuts

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