util

package
v0.0.0-...-e165b3a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(bytes []byte) []byte

Encode 编码数据

Types

type Codec

type Codec struct {
	Conn    net.Conn
	ReadBuf *common.Buffer // 读缓冲
}

Codec 编解码器,用来处理tcp的拆包粘包

func NewCodec

func NewCodec(conn net.Conn) *Codec

NewCodec 创建一个编解码器

func (*Codec) Decode

func (c *Codec) Decode() ([]byte, bool, error)

Decode 解码数据 Package 代表一个解码包 bool 标识是否还有可读数据

func (*Codec) Read

func (c *Codec) Read() (int, error)

Read 从conn里面读取数据,当conn发生阻塞,这个方法也会阻塞

Jump to

Keyboard shortcuts

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