memipnet

package module
v0.0.0-...-584bb64 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

Hermetic Go net package TCP and UDP loopback implementations GoDoc

Allows fully hermetic testing of code which depends on TCP and/or UDP loopback networking. Useful for all cases where a TCP or UDP loopback sockets would be used and all use is confined to a single process and goes through the net package.

This is a more compatible, but heavier weight alternative to memnet.

This package uses gVisor's pure Go network stack.

Documentation

Overview

Package memipnet provides hermetic net package TCP and UDP loopback implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

A Stack is a hermetic network stack emulator.

func NewStack

func NewStack() (*Stack, error)

NewStack creates a new hermetic network stack emulator.

func (*Stack) Close

func (s *Stack) Close()

Close releases all resources owned by this Stack.

Close does no prevent additional uses of this Stack.

func (*Stack) Dial

func (s *Stack) Dial(network, address string) (net.Conn, error)

Dial connects to the address on the named network.

See net.Dial for a description of the network and address parameters.

func (*Stack) DialContext

func (s *Stack) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext connects to the address on the named network using the provided context.

See net.Dial for a description of the network and address parameters.

func (*Stack) Listen

func (s *Stack) Listen(ctx context.Context, network, address string) (net.Listener, error)

Listen announces on the emulated local network address.

See net.Listen for a description of the network and address parameters.

func (*Stack) ListenPacket

func (s *Stack) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)

ListenPacket announces on the emulated local network address.

See net.ListenPacket for a description of the network and address parameters.

Jump to

Keyboard shortcuts

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