Documentation ¶
Overview ¶
Package delayconn implements many smart net.Conn.
Index ¶
- func OneByteWriter(w io.Writer) io.Writer
- type DelayConn
- func (rc *DelayConn) Close() error
- func (rc *DelayConn) LocalAddr() net.Addr
- func (rc *DelayConn) Read(b []byte) (n int, err error)
- func (rc *DelayConn) RemoteAddr() net.Addr
- func (rc *DelayConn) SetDeadline(t time.Time) error
- func (rc *DelayConn) SetReadDeadline(t time.Time) error
- func (rc *DelayConn) SetWriteDeadline(t time.Time) error
- func (rc *DelayConn) Write(b []byte) (n int, err error)
- type OneByteReadConn
- func (rc *OneByteReadConn) Close() error
- func (rc *OneByteReadConn) LocalAddr() net.Addr
- func (rc *OneByteReadConn) Read(b []byte) (n int, err error)
- func (rc *OneByteReadConn) RemoteAddr() net.Addr
- func (rc *OneByteReadConn) SetDeadline(t time.Time) error
- func (rc *OneByteReadConn) SetReadDeadline(t time.Time) error
- func (rc *OneByteReadConn) SetWriteDeadline(t time.Time) error
- func (rc *OneByteReadConn) Write(b []byte) (n int, err error)
- type OneByteWriteConn
- func (rc *OneByteWriteConn) Close() error
- func (rc *OneByteWriteConn) LocalAddr() net.Addr
- func (rc *OneByteWriteConn) Read(b []byte) (n int, err error)
- func (rc *OneByteWriteConn) RemoteAddr() net.Addr
- func (rc *OneByteWriteConn) SetDeadline(t time.Time) error
- func (rc *OneByteWriteConn) SetReadDeadline(t time.Time) error
- func (rc *OneByteWriteConn) SetWriteDeadline(t time.Time) error
- func (rc *OneByteWriteConn) Write(b []byte) (n int, err error)
- type PerWriteDelayConn
- func (rc *PerWriteDelayConn) Close() error
- func (rc *PerWriteDelayConn) LocalAddr() net.Addr
- func (rc *PerWriteDelayConn) Read(b []byte) (n int, err error)
- func (rc *PerWriteDelayConn) RemoteAddr() net.Addr
- func (rc *PerWriteDelayConn) SetDeadline(t time.Time) error
- func (rc *PerWriteDelayConn) SetReadDeadline(t time.Time) error
- func (rc *PerWriteDelayConn) SetWriteDeadline(t time.Time) error
- func (rc *PerWriteDelayConn) Write(b []byte) (n int, err error)
- type ReadDelayConn
- func (rc *ReadDelayConn) Close() error
- func (rc *ReadDelayConn) LocalAddr() net.Addr
- func (rc *ReadDelayConn) Read(b []byte) (n int, err error)
- func (rc *ReadDelayConn) RemoteAddr() net.Addr
- func (rc *ReadDelayConn) SetDeadline(t time.Time) error
- func (rc *ReadDelayConn) SetReadDeadline(t time.Time) error
- func (rc *ReadDelayConn) SetWriteDeadline(t time.Time) error
- func (rc *ReadDelayConn) Write(b []byte) (n int, err error)
- type WriteDelayConn
- func (rc *WriteDelayConn) Close() error
- func (rc *WriteDelayConn) LocalAddr() net.Addr
- func (rc *WriteDelayConn) Read(b []byte) (n int, err error)
- func (rc *WriteDelayConn) RemoteAddr() net.Addr
- func (rc *WriteDelayConn) SetDeadline(t time.Time) error
- func (rc *WriteDelayConn) SetReadDeadline(t time.Time) error
- func (rc *WriteDelayConn) SetWriteDeadline(t time.Time) error
- func (rc *WriteDelayConn) Write(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DelayConn ¶
type DelayConn struct {
// contains filtered or unexported fields
}
DelayConn delay the read and write operations.
func NewDelayConn ¶
NewDelayConn creates a new DelayConn.
func (*DelayConn) Close ¶
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*DelayConn) Read ¶
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 (*DelayConn) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (*DelayConn) SetDeadline ¶
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 with a timeout (see type Error) 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.
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.
Note that if a TCP connection has keep-alive turned on, which is the default unless overridden by Dialer.KeepAlive or ListenConfig.KeepAlive, then a keep-alive failure may also return a timeout error. On Unix systems a keep-alive failure on I/O can be detected using errors.Is(err, syscall.ETIMEDOUT).
func (*DelayConn) SetReadDeadline ¶
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 (*DelayConn) SetWriteDeadline ¶
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 OneByteReadConn ¶
type OneByteReadConn struct {
// contains filtered or unexported fields
}
OneByteReadConn sets the delay for read operations.
func NewOneByteReadConn ¶
func NewOneByteReadConn(conn net.Conn) *OneByteReadConn
func (*OneByteReadConn) Close ¶
func (rc *OneByteReadConn) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*OneByteReadConn) LocalAddr ¶
func (rc *OneByteReadConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*OneByteReadConn) Read ¶
func (rc *OneByteReadConn) 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 (*OneByteReadConn) RemoteAddr ¶
func (rc *OneByteReadConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.
func (*OneByteReadConn) SetDeadline ¶
func (rc *OneByteReadConn) 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 with a timeout (see type Error) 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.
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.
Note that if a TCP connection has keep-alive turned on, which is the default unless overridden by Dialer.KeepAlive or ListenConfig.KeepAlive, then a keep-alive failure may also return a timeout error. On Unix systems a keep-alive failure on I/O can be detected using errors.Is(err, syscall.ETIMEDOUT).
func (*OneByteReadConn) SetReadDeadline ¶
func (rc *OneByteReadConn) 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 (*OneByteReadConn) SetWriteDeadline ¶
func (rc *OneByteReadConn) 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 OneByteWriteConn ¶
type OneByteWriteConn struct {
// contains filtered or unexported fields
}
OneByteWriteConn guarantees write a one bytes every time.
func NewOneByteWriteConn ¶
func NewOneByteWriteConn(conn net.Conn) *OneByteWriteConn
NewOneByteWriteConn creates a new OneByteWriteConn.
func (*OneByteWriteConn) Close ¶
func (rc *OneByteWriteConn) Close() error
Close closes the connection. Any blocked Write or Write operations will be unblocked and return errors.
func (*OneByteWriteConn) LocalAddr ¶
func (rc *OneByteWriteConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*OneByteWriteConn) Read ¶
func (rc *OneByteWriteConn) Read(b []byte) (n int, err error)
Write Writes data from 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.
func (*OneByteWriteConn) RemoteAddr ¶
func (rc *OneByteWriteConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.
func (*OneByteWriteConn) SetDeadline ¶
func (rc *OneByteWriteConn) SetDeadline(t time.Time) error
SetDeadline sets the Write and write deadlines associated with the connection. It is equivalent to calling both SetWriteDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Write or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful Write or Write calls.
A zero value for t means I/O operations will not time out.
Note that if a TCP connection has keep-alive turned on, which is the default unless overridden by Dialer.KeepAlive or ListenConfig.KeepAlive, then a keep-alive failure may also return a timeout error. On Unix systems a keep-alive failure on I/O can be detected using errors.Is(err, syscall.ETIMEDOUT).
func (*OneByteWriteConn) SetReadDeadline ¶
func (rc *OneByteWriteConn) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls
func (*OneByteWriteConn) SetWriteDeadline ¶
func (rc *OneByteWriteConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. A zero value for t means Write will not time out.
type PerWriteDelayConn ¶
type PerWriteDelayConn struct {
// contains filtered or unexported fields
}
PerWriteDelayConn implements the delay before Write.
func NewPerWriteDelayConn ¶
func NewPerWriteDelayConn(delay time.Duration, conn net.Conn) *PerWriteDelayConn
NewPerWriteDelayConn returns a new PerWriteDelayConn.
func (*PerWriteDelayConn) Close ¶
func (rc *PerWriteDelayConn) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*PerWriteDelayConn) LocalAddr ¶
func (rc *PerWriteDelayConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*PerWriteDelayConn) Read ¶
func (rc *PerWriteDelayConn) 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 (*PerWriteDelayConn) RemoteAddr ¶
func (rc *PerWriteDelayConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.
func (*PerWriteDelayConn) SetDeadline ¶
func (rc *PerWriteDelayConn) 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 with a timeout (see type Error) 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.
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.
Note that if a TCP connection has keep-alive turned on, which is the default unless overridden by Dialer.KeepAlive or ListenConfig.KeepAlive, then a keep-alive failure may also return a timeout error. On Unix systems a keep-alive failure on I/O can be detected using errors.Is(err, syscall.ETIMEDOUT).
func (*PerWriteDelayConn) SetReadDeadline ¶
func (rc *PerWriteDelayConn) 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 (*PerWriteDelayConn) SetWriteDeadline ¶
func (rc *PerWriteDelayConn) 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 ReadDelayConn ¶
type ReadDelayConn struct {
// contains filtered or unexported fields
}
ReadDelayConn sets the read delay operations.
func NewReadDelayConn ¶
func NewReadDelayConn(delay time.Duration, conn net.Conn) *ReadDelayConn
NewReadDelayConn creates a new ReadDelayConn.
func (*ReadDelayConn) Close ¶
func (rc *ReadDelayConn) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*ReadDelayConn) LocalAddr ¶
func (rc *ReadDelayConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*ReadDelayConn) Read ¶
func (rc *ReadDelayConn) 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 (*ReadDelayConn) RemoteAddr ¶
func (rc *ReadDelayConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.
func (*ReadDelayConn) SetDeadline ¶
func (rc *ReadDelayConn) 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 with a timeout (see type Error) 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.
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.
Note that if a TCP connection has keep-alive turned on, which is the default unless overridden by Dialer.KeepAlive or ListenConfig.KeepAlive, then a keep-alive failure may also return a timeout error. On Unix systems a keep-alive failure on I/O can be detected using errors.Is(err, syscall.ETIMEDOUT).
func (*ReadDelayConn) SetReadDeadline ¶
func (rc *ReadDelayConn) 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 (*ReadDelayConn) SetWriteDeadline ¶
func (rc *ReadDelayConn) 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 WriteDelayConn ¶
type WriteDelayConn struct {
// contains filtered or unexported fields
}
WriteDelayConn implements the delay before Write.
func NewWriteDelayConn ¶
func NewWriteDelayConn(delay time.Duration, conn net.Conn) *WriteDelayConn
NewWriteDelayConn returns a new WriteDelayConn.
func (*WriteDelayConn) Close ¶
func (rc *WriteDelayConn) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*WriteDelayConn) LocalAddr ¶
func (rc *WriteDelayConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*WriteDelayConn) Read ¶
func (rc *WriteDelayConn) 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 (*WriteDelayConn) RemoteAddr ¶
func (rc *WriteDelayConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.
func (*WriteDelayConn) SetDeadline ¶
func (rc *WriteDelayConn) 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 with a timeout (see type Error) 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.
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.
Note that if a TCP connection has keep-alive turned on, which is the default unless overridden by Dialer.KeepAlive or ListenConfig.KeepAlive, then a keep-alive failure may also return a timeout error. On Unix systems a keep-alive failure on I/O can be detected using errors.Is(err, syscall.ETIMEDOUT).
func (*WriteDelayConn) SetReadDeadline ¶
func (rc *WriteDelayConn) 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 (*WriteDelayConn) SetWriteDeadline ¶
func (rc *WriteDelayConn) 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.