udpblock

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLenHead

func AddLenHead(data []byte) []byte

AddLenHead 是在数据的头部增加长度数据,用以在流式输出的连接中传输不粘包的数据

func GetData

func GetData(data []byte) ([]byte, error)

GetData 是从数据中获取真正的数据分片,如果数据并没有使用 AddLenHead 操作过,则该函数不能正确工作

func NewDataReader

func NewDataReader(conn DeadlineReader) (io.ReadCloser, error)

func NewDataWriter

func NewDataWriter(conn io.Writer) (io.Writer, error)

Types

type DeadlineReader

type DeadlineReader interface {
	Read(b []byte) (n int, err error)
	SetReadDeadline(t time.Time) error
}

DeadlineReader 是 io.Reader 加上 SetReadDeadline 方法的接口

Jump to

Keyboard shortcuts

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