conn

package
v1.1.2-pre Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package conn 底层的连接的抽象

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(dst Conn, conn Conn) (err error)

Join 将一条普通连接加入到连接池

func Listen

func Listen(addr string) (acceptCh chan Conn, errCh chan error)

Listen 监听一个地址 返回两个管道 一个是建立成功的连接的管道,一个是错误的管道 如果监听出现错误,errCh写一个错误进去,然后关闭两个管道

Types

type Conn

type Conn interface {
	Write(opcode byte, data []byte) error        // 写数据,线程安全
	Recv() (opcode byte, data []byte, err error) // 读数据
	Addr() string
	Close() // 关闭连接
}

Conn 连接的抽象接口

func Dial

func Dial(addr string) (c Conn, err error)

Dial 对一个地址建立一条tcp连接

func Upgrade

func Upgrade(conn Conn) (Conn, error)

Upgrade 将一条普通连接升级为连接池

Jump to

Keyboard shortcuts

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