Documentation ¶
Index ¶
- func NewReadWriteCloser(reader io.ReadCloser, writer io.WriteCloser) io.ReadWriteCloser
- type Conn
- func (p *Conn) Close() error
- func (p *Conn) LocalAddr() net.Addr
- func (p *Conn) Read(b []byte) (n int, err error)
- func (p *Conn) RemoteAddr() net.Addr
- func (p *Conn) SetDeadline(t time.Time) error
- func (p *Conn) SetReadDeadline(t time.Time) error
- func (p *Conn) SetWriteDeadline(t time.Time) error
- func (p *Conn) Write(pkt []byte) (n int, err error)
- type ConnAddr
- type ConnAddrBase
- type PacketConn
- func (p *PacketConn) Close() error
- func (p *PacketConn) LocalAddr() net.Addr
- func (p *PacketConn) ReadFrom(pk []byte) (n int, addr net.Addr, err error)
- func (p *PacketConn) RemoteAddr() net.Addr
- func (p *PacketConn) SetDeadline(t time.Time) error
- func (p *PacketConn) SetReadDeadline(t time.Time) error
- func (p *PacketConn) SetWriteDeadline(t time.Time) error
- func (p *PacketConn) WriteTo(pkt []byte, addr net.Addr) (n int, err error)
- type ReadWriteCloser
- type RwcOverlay
- func (r *RwcOverlay) Close() error
- func (r *RwcOverlay) LocalAddr() net.Addr
- func (r *RwcOverlay) Read(b []byte) (n int, err error)
- func (r *RwcOverlay) RemoteAddr() net.Addr
- func (r *RwcOverlay) SetDeadline(t time.Time) error
- func (r *RwcOverlay) SetReadDeadline(t time.Time) error
- func (r *RwcOverlay) SetWriteDeadline(t time.Time) error
- func (r *RwcOverlay) Write(b []byte) (n int, err error)
- type RwcPacketConn
- func (pc *RwcPacketConn) Close() error
- func (pc *RwcPacketConn) LocalAddr() net.Addr
- func (pc *RwcPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (pc *RwcPacketConn) SetDeadline(t time.Time) error
- func (pc *RwcPacketConn) SetReadDeadline(t time.Time) error
- func (pc *RwcPacketConn) SetWriteDeadline(t time.Time) error
- func (pc *RwcPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewReadWriteCloser ¶
func NewReadWriteCloser( reader io.ReadCloser, writer io.WriteCloser, ) io.ReadWriteCloser
NewReadWriteCloser builds a new ReadWriteCloser.
Types ¶
type Conn ¶ added in v0.7.2
type Conn struct {
// contains filtered or unexported fields
}
Conn implements a Conn with a buffered ReadWriteCloser.
func NewConn ¶ added in v0.7.2
func NewConn( ctx context.Context, rwc io.ReadWriteCloser, laddr, raddr net.Addr, bufferPacketN int, ) *Conn
NewConn constructs a new packet conn and starts the rx pump.
func (*Conn) Close ¶ added in v0.7.2
Close closes the connection. Any blocked ReadFrom or WriteTo operations will be unblocked and return errors.
func (*Conn) Read ¶ added in v0.7.2
Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*Conn) RemoteAddr ¶ added in v0.7.2
RemoteAddr returns the bound remote network address.
func (*Conn) SetDeadline ¶ added in v0.7.2
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending the deadline after successful ReadFrom or WriteTo calls.
A zero value for t means I/O operations will not time out.
func (*Conn) SetReadDeadline ¶ added in v0.7.2
SetReadDeadline sets the deadline for future ReadFrom calls and any currently-blocked ReadFrom call. A zero value for t means ReadFrom will not time out.
func (*Conn) SetWriteDeadline ¶ added in v0.7.2
SetWriteDeadline sets the deadline for future WriteTo calls and any currently-blocked WriteTo call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means WriteTo will not time out.
type ConnAddr ¶ added in v0.8.0
type ConnAddr struct { ConnAddrBase // contains filtered or unexported fields }
ConnAddr overlays LocalAddr and RemoteAddr on a base Conn.
func NewConnAddr ¶ added in v0.8.0
func NewConnAddr(base ConnAddrBase, local, remote net.Addr) *ConnAddr
NewConnAddr constructs a new ConnAddr.
func (*ConnAddr) RemoteAddr ¶ added in v0.8.0
RemoteAddr returns the remote network address, if known.
type ConnAddrBase ¶ added in v0.8.0
type ConnAddrBase interface { // Read can be made to time out and return an error after a fixed // time limit; see SetDeadline and SetReadDeadline. Read(b []byte) (n int, err error) // Write writes data to the connection. // Write can be made to time out and return an error after a fixed // time limit; see SetDeadline and SetWriteDeadline. Write(b []byte) (n int, err error) // Close closes the connection. // Any blocked Read or Write operations will be unblocked and return errors. Close() error // SetDeadline sets the read and write deadlines associated // with the connection. It is equivalent to calling both // SetReadDeadline and SetWriteDeadline. // // A deadline is an absolute time after which I/O operations // fail instead of blocking. The deadline applies to all future // and pending I/O, not just the immediately following call to // Read or Write. After a deadline has been exceeded, the // connection can be refreshed by setting a deadline in the future. // // If the deadline is exceeded a call to Read or Write or to other // I/O methods will return an error that wraps os.ErrDeadlineExceeded. // This can be tested using errors.Is(err, os.ErrDeadlineExceeded). // The error's Timeout method will return true, but note that there // are other possible errors for which the Timeout method will // return true even if the deadline has not been exceeded. // // An idle timeout can be implemented by repeatedly extending // the deadline after successful Read or Write calls. // // A zero value for t means I/O operations will not time out. SetDeadline(t time.Time) error // SetReadDeadline sets the deadline for future Read calls // and any currently-blocked Read call. // A zero value for t means Read will not time out. SetReadDeadline(t time.Time) error // SetWriteDeadline sets the deadline for future Write calls // and any currently-blocked Write call. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. // A zero value for t means Write will not time out. SetWriteDeadline(t time.Time) error }
ConnAddrBase is the base type for ConnAddr.
type PacketConn ¶
type PacketConn struct {
// contains filtered or unexported fields
}
PacketConn implements a PacketConn with a Read-Write-Closer.
Writes a little-endian 4 byte length prefix before each packet. All messages sent to/from the wrong addresses are dropped.
func NewPacketConn ¶
func NewPacketConn( ctx context.Context, rwc io.ReadWriteCloser, laddr, raddr net.Addr, maxPacketSize uint32, bufferPacketN int, ) *PacketConn
NewPacketConn constructs a new packet conn and starts the rx pump.
func (*PacketConn) Close ¶
func (p *PacketConn) Close() error
Close closes the connection. Any blocked ReadFrom or WriteTo operations will be unblocked and return errors.
func (*PacketConn) LocalAddr ¶
func (p *PacketConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*PacketConn) ReadFrom ¶
ReadFrom reads a packet from the connection, copying the payload into p. It returns the number of bytes copied into p and the return address that was on the packet. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Callers should always process the n > 0 bytes returned before considering the error err. ReadFrom can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*PacketConn) RemoteAddr ¶
func (p *PacketConn) RemoteAddr() net.Addr
RemoteAddr returns the bound remote network address.
func (*PacketConn) SetDeadline ¶
func (p *PacketConn) 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.
A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending the deadline after successful ReadFrom or WriteTo calls.
A zero value for t means I/O operations will not time out.
func (*PacketConn) SetReadDeadline ¶
func (p *PacketConn) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future ReadFrom calls and any currently-blocked ReadFrom call. A zero value for t means ReadFrom will not time out.
func (*PacketConn) SetWriteDeadline ¶
func (p *PacketConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future WriteTo calls and any currently-blocked WriteTo call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means WriteTo will not time out.
type ReadWriteCloser ¶
type ReadWriteCloser struct {
// contains filtered or unexported fields
}
ReadWriteCloser implements ReadWriteCloser with a Reader and Writer.
type RwcOverlay ¶ added in v0.8.0
type RwcOverlay struct {
// contains filtered or unexported fields
}
RwcOverlay overlays a io.ReadWriteCloser on a net.Conn.
func NewRwcOverlay ¶ added in v0.8.0
func NewRwcOverlay(rwc io.ReadWriteCloser, nc net.Conn) *RwcOverlay
NewRwcOverlay builds a ReadWriteCloser overlayed on a net.Conn.
func (*RwcOverlay) Close ¶ added in v0.8.0
func (r *RwcOverlay) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*RwcOverlay) LocalAddr ¶ added in v0.8.0
func (r *RwcOverlay) LocalAddr() net.Addr
LocalAddr returns the local network address, if known.
func (*RwcOverlay) Read ¶ added in v0.8.0
func (r *RwcOverlay) Read(b []byte) (n int, err error)
Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*RwcOverlay) RemoteAddr ¶ added in v0.8.0
func (r *RwcOverlay) RemoteAddr() net.Addr
RemoteAddr returns the remote network address, if known.
func (*RwcOverlay) SetDeadline ¶ added in v0.8.0
func (r *RwcOverlay) 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.
A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*RwcOverlay) SetReadDeadline ¶ added in v0.8.0
func (r *RwcOverlay) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*RwcOverlay) SetWriteDeadline ¶ added in v0.8.0
func (r *RwcOverlay) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.
type RwcPacketConn ¶ added in v0.22.0
type RwcPacketConn struct {
// contains filtered or unexported fields
}
RwcPacketConn wraps a ReadWriteCloser to implement net.PacketConn.
Read and write deadlines are not implemented. The addresses are ignored when reading / writing.
func NewRwcPacketConn ¶ added in v0.22.0
func NewRwcPacketConn(rwc io.ReadWriteCloser, laddr, raddr net.Addr) *RwcPacketConn
NewRwcPacketConn creates a new RwcPacketConn with the provided ReadWriteCloser and local/remote addresses.
func (*RwcPacketConn) Close ¶ added in v0.22.0
func (pc *RwcPacketConn) Close() error
Close closes the connection.
func (*RwcPacketConn) LocalAddr ¶ added in v0.22.0
func (pc *RwcPacketConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*RwcPacketConn) ReadFrom ¶ added in v0.22.0
ReadFrom reads a packet from the connection, ignoring the provided address.
func (*RwcPacketConn) SetDeadline ¶ added in v0.22.0
func (pc *RwcPacketConn) SetDeadline(t time.Time) error
SetDeadline sets the read and write deadlines associated with the connection. No-op: RwcPacketConn does not support deadlines
func (*RwcPacketConn) SetReadDeadline ¶ added in v0.22.0
func (pc *RwcPacketConn) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls. No-op: RwcPacketConn does not support deadlines
func (*RwcPacketConn) SetWriteDeadline ¶ added in v0.22.0
func (pc *RwcPacketConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls. No-op: RwcPacketConn does not support deadlines