Documentation ¶
Index ¶
- Variables
- func Dial(netw, addr string) (net.Conn, error)
- func Listen(netw, laddr string) (net.Listener, error)
- func ListenOpts(netw, laddr string, inOpts, outOpts Options) (net.Listener, error)
- func NetPipe(opt0, opt1 Options) (c0 net.Conn, c1 net.Conn)
- func NewConn(c net.Conn, inOpts, outOpts Options) net.Conn
- func Pipe(opt Options) (r io.ReadCloser, w io.WriteCloser)
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrPipeWrite = errors.New("write on closed pipe")
Functions ¶
func Dial ¶
Dial is the same as net.Dial except that it also recognises networks with the prefix "loopback:"; it removes the prefix, dials the original network, and then applies the given loopback Options. Incoming data has inOpts applied; outgoing data has outOpts applied.
func Listen ¶
Dial is the same as net.Listen except that it also recognises networks with the [attr=val, attr=val, ...]network; it removes the prefix, listens on the original network, and then applies the given loopback Options to each connection. Incoming data has inOpts applied; outgoing data has outOpts applied.
func ListenOpts ¶
func NetPipe ¶
NetPipe creates a synchronous, in-memory, full duplex network connection; both ends implement the net.Conn interface. The opt0 options apply to the traffic from c0 to c1; the opt1 options apply to the traffic from c1 to c0.
func Pipe ¶
func Pipe(opt Options) (r io.ReadCloser, w io.WriteCloser)
Pipe creates an asynchronous in-memory pipe, Writes are divided into packets of at most opts.MTU bytes written to a flow-controlled output queue, transferred across the link, and put into an input queue where it is readable with the r. The options determine when and how the data will be transferred.
Types ¶
type Options ¶
type Options struct { // ByteDelay controls the time a packet takes in the link. A // packet n bytes long takes time ByteDelay * n to exit the // output queue and is available for reading Latency time later. ByteDelay time.Duration Latency time.Duration // MTU gives the maximum packet size that can be tranferred // atomically across the link. Larger packets will be split. // If this is zero, a default of 32768 is assumed MTU int // InLimit and OutLimit gives the size of the input and output // queues. If either is zero, a default of MTU is assumed. InLimit int OutLimit int }
Loopback options for use with Pipe.