tcp

package
v0.0.0-...-34dd132 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(addr string, cb func(*net.TCPConn))

NewServer make TCP server

func Optimize

func Optimize(conn *net.TCPConn) (err error)

Optimize TCP connect optimize

func Read

func Read(conn *net.TCPConn, timeout time.Duration, p []byte) (n int, isTimeout bool, err error)

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.

func Write

func Write(conn *net.TCPConn, timeout time.Duration, data []byte) (n int, isTimeout bool, err error)

Write tcp write

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL