tcpnet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client 客户端

func (*Client) Close

func (client *Client) Close()

Close 关闭客户端连接

func (*Client) IsConnected

func (client *Client) IsConnected() bool

IsConnected 是否处于连接状态

func (*Client) Run

func (client *Client) Run()

Run 执行主逻辑

func (*Client) Start

func (client *Client) Start(address string, newAgent core.GetAgent, opts ...core.ClientOption) error

Start 开启客户端连接

type Conn

type Conn struct {
	sync.Mutex
	codec.ConnHelper
	// contains filtered or unexported fields
}

Conn tcp 连接

func (*Conn) Close

func (tcpConn *Conn) Close()

Close 断连

func (*Conn) Init

func (tcpConn *Conn) Init(conn net.Conn, codec core.Codec)

Init 初始化

func (*Conn) LocalAddr

func (tcpConn *Conn) LocalAddr() net.Addr

LocalAddr 本地socket端口地址

func (*Conn) RemoteAddr

func (tcpConn *Conn) RemoteAddr() net.Addr

RemoteAddr 远程socket端口地址

func (*Conn) Run

func (tcpConn *Conn) Run()

Run 循环运行

func (*Conn) Write

func (tcpConn *Conn) Write(b []byte) (n int, err error)

Write b 必须在其他协程中不被修改

type Server

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

Server tcp 服务器

func (*Server) Close

func (server *Server) Close()

Close 关闭TCP监听

func (*Server) GetConnNum

func (server *Server) GetConnNum() (num int)

GetConnNum 获取所有连接的数量

func (*Server) Run

func (server *Server) Run()

Run 执行服务端逻辑

func (*Server) Start

func (server *Server) Start(address string, newAgent core.GetAgent, opts ...core.ServerOption) error

Start 开始tcp监听

Jump to

Keyboard shortcuts

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