conn

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateChan

func CreateChan() (chan *TData, uint64)

CreateChan 创建一个通道

func DeleteChan

func DeleteChan(nIndex uint64)

DeleteChan 删除掉chan

func FindChan

func FindChan(nIndex uint64) chan *TData

FindChan 查找chan

func RangeConnection added in v1.0.3

func RangeConnection(f func(key, value interface{}) bool)

RangeConnection 遍历

Types

type IConn

type IConn interface {
	Read(b []byte) (int, error)
	Write(buff []byte) (int, error)
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	Close() error
}

IConn 连接接口

type TConnection

type TConnection struct {
	// contains filtered or unexported fields
}

TConnection 上下文会话

func CreateConnection

func CreateConnection(pConn IConn) *TConnection

CreateConnection 创建一个新的连接

func FindConnection

func FindConnection(nIndex uint64) *TConnection

FindConnection 查找

func (*TConnection) Close

func (self *TConnection) Close() error

Close 关闭连接

func (*TConnection) GetConn

func (self *TConnection) GetConn() IConn

GetConn 得到连接指针

func (*TConnection) GetIndex

func (self *TConnection) GetIndex() uint64

GetIndex 获取索引值

func (*TConnection) LocalAddr

func (self *TConnection) LocalAddr() net.Addr

LocalAddr 本地socket端口地址

func (*TConnection) Read

func (self *TConnection) Read(b []byte) (int, error)

Read 读取字节

func (*TConnection) RemoteAddr

func (self *TConnection) RemoteAddr() net.Addr

RemoteAddr 远程socket端口地址

func (*TConnection) SetDeadline

func (self *TConnection) SetDeadline(t time.Time) error

SetDeadline 设置超时时间 t = 0 意味着I/O操作不会超时。

func (*TConnection) SetReadDeadline

func (self *TConnection) SetReadDeadline(t time.Time) error

SetReadDeadline 设置读取的超时时间 t = 0 意味着I/O操作不会超时。

func (*TConnection) Write

func (self *TConnection) Write(buff []byte) (int, error)

Write 写字节

func (*TConnection) WritePack

func (self *TConnection) WritePack(buff []byte) (int, error)

WritePack 写字节, 并且自动补齐包头部分

type TData

type TData struct {
	// contains filtered or unexported fields
}

TData 数据

func NewData

func NewData(buff []byte, nLen int, p *TConnection) *TData

NewData 设置数据

func (*TData) GetBuffer

func (self *TData) GetBuffer() []byte

GetBuffer 获取buffer

func (*TData) GetConnection

func (self *TData) GetConnection() *TConnection

GetConnection 获取连接

func (*TData) GetIndex

func (self *TData) GetIndex() uint64

GetIndex 获取自增索引

func (*TData) GetLength

func (self *TData) GetLength() int

GetLength 获取长度

func (*TData) Print

func (self *TData) Print()

Print 打印

Jump to

Keyboard shortcuts

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