network

package
v0.0.0-...-168a2c3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FakeDialer

func FakeDialer(from string) func(context.Context, string) (net.Conn, error)

FakeDialer returns fake connection creator.

func FakeListener

func FakeListener(addr string) net.Listener

FakeListener returns fake listener binded to addr. Leave addr empty to get any free addr.

func TCPListener

func TCPListener(addr string) net.Listener

TCPListener returns TCP listener binded to addr. Leave addr empty to get any free addr.

Types

type Addr

type Addr string

Addr represents a fake network end point address.

func (Addr) Network

func (a Addr) Network() string

Network returns name of the network. It can be passed as the arguments to Dial().

func (Addr) String

func (a Addr) String() string

String returns string form of the network address.

type Conn

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

Conn is a stream-oriented fake network connection. Multiple goroutines may invoke methods on a Conn simultaneously.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read reads data from the connection. Read can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline. It is not implemented.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. It is not implemented.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. It is not implemented.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write writes data to the connection. Write can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.

type ListenFunc

type ListenFunc func(addr string) net.Listener

ListenFunc returns addr listener.

type Listener

type Listener struct {
	NetAddr Addr

	sync.RWMutex
	// contains filtered or unexported fields
}

Listener is a fake net listener.

func NewListener

func NewListener(addr Addr) *Listener

NewListener makes fake listener.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

Jump to

Keyboard shortcuts

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