Documentation ¶
Overview ¶
Package memnet implements an in-memory network implementation. It is useful for dialing and listening on in-memory addresses in tests and other situations where you don't want to use the network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn interface { net.Conn // SetReadBlock blocks or unblocks the Read method of this Conn. // It reports an error if the existing value matches the new value, // or if the Conn has been Closed. SetReadBlock(bool) error // SetWriteBlock blocks or unblocks the Write method of this Conn. // It reports an error if the existing value matches the new value, // or if the Conn has been Closed. SetWriteBlock(bool) error }
Conn is a net.Conn that can additionally have its reads and writes blocked and unblocked.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is a net.Listener using NewConn to create pairs of network connections connected in memory using a buffered pipe. It also provides a Dial method to establish new connections.
func (*Listener) Accept ¶
Accept blocks until a new connection is available or the listener is closed.
type Pipe ¶
type Pipe struct {
// contains filtered or unexported fields
}
Pipe implements an in-memory FIFO with timeouts.
func (*Pipe) Block ¶
Block will cause all calls to Read and Write to block until they either timeout, are unblocked or the pipe is closed.
func (*Pipe) Read ¶
Read implements io.Reader. Once the buffer is drained (i.e. after Close), subsequent calls will return io.EOF.
func (*Pipe) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls.
func (*Pipe) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls.