tcp

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout Default Header timeout
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func Dial

func Dial(network, address string, header byte) (net.Conn, error)

Dial 基于初始的 Header 字节与远程的 mux 监听器建立连接

Types

type Mux

type Mux struct {

	// Receive Header timeout
	Timeout time.Duration

	// Out-of-band error logger
	Logger *log.Logger
	// contains filtered or unexported fields
}

Mux Reusable connections

func NewMux

func NewMux() *Mux

NewMux 返回可复用的网络连接对象 Mux 的实例

func (*Mux) DefaultListener

func (mux *Mux) DefaultListener() net.Listener

DefaultListener 创建默认的 net.Listener 监听器实例,用于处理未注册 Header 字节的连接。 读取数据时,之前已被读取的 Header 字节将会被重新读取。

注册该默认监听器实例时,需要确保请求报文的起始字节与其他已注册 Header 字节的监听器之间没有冲突, 如 GET 请求中的 71 ('G')

func (*Mux) Listen

func (mux *Mux) Listen(header byte) net.Listener

Listen 在 mux 中,创建唯一基于 Header 字节的监听器实例

func (*Mux) Serve

func (mux *Mux) Serve(ln net.Listener) error

Serve 开始维护通过 ln 建立的连接。 ln 可通过注册基于 Header 字节 的监听器实现复用

Jump to

Keyboard shortcuts

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