Documentation ¶
Index ¶
- func NewServer(addr string, cb func(*net.TCPConn))
- func Optimize(conn *net.TCPConn) (err error)
- func Read(conn *net.TCPConn, timeout time.Duration, p []byte) (n int, isTimeout bool, err error)
- func ReadBytes(conn *net.TCPConn, timeout time.Duration, delim byte) (data []byte, isTimeout bool, err error)
- func Write(conn *net.TCPConn, timeout time.Duration, data []byte) (n int, isTimeout bool, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
Read tcp reads data into p. It returns the number of bytes read into p. The bytes are taken from at most one Read on the underlying Reader, hence n may be less than len(p). To read exactly len(p) bytes, use io.ReadFull(b, p). At EOF, the count will be zero and err will be io.EOF.
func ReadBytes ¶
func ReadBytes(conn *net.TCPConn, timeout time.Duration, delim byte) (data []byte, isTimeout bool, err error)
ReadBytes tcp reads until the first occurrence of delim in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadBytes returns err != nil if and only if the returned data does not end in delim. For simple uses, a Scanner may be more convenient.
Types ¶
This section is empty.