connection

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseCallback

type CloseCallback func(c *Connection)

CloseCallback 关闭回调函数

type Connection

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

Connection TCP 连接

func New

func New(fd int, loop *eventloop.EventLoop, sa *unix.Sockaddr, readCb ReadCallback, closeCb CloseCallback) *Connection

New 创建 Connection

func (*Connection) Connected

func (c *Connection) Connected() bool

Connected 是否已连接

func (*Connection) Context

func (c *Connection) Context() interface{}

Context 获取 Context

func (*Connection) HandleEvent

func (c *Connection) HandleEvent(fd int, events poller.Event)

HandleEvent 内部使用,event loop 回调

func (*Connection) PeerAddr

func (c *Connection) PeerAddr() string

PeerAddr 获取客户端地址信息

func (*Connection) Send

func (c *Connection) Send(buffer []byte) error

Send 用来在非 loop 协程发送

func (*Connection) SetContext

func (c *Connection) SetContext(ctx interface{})

SetContext 设置 Context

func (*Connection) ShutdownWrite

func (c *Connection) ShutdownWrite() error

ShutdownWrite 关闭可写端,等待读取完接收缓冲区所有数据

type ReadCallback

type ReadCallback func(c *Connection, buffer *ringbuffer.RingBuffer) []byte

ReadCallback 数据可读回调函数

Jump to

Keyboard shortcuts

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