network

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: 7 Imported by: 0

Documentation

Overview

Package network 提供了更上层的网络接口

Example Usage

id, err := network.Listen(network.TcpGNet, ":6699", agent.GetSingleAgent)

Index

Constants

View Source
const (
	// TcpSeries 从 0 开始,TCP系列不同的实现
	TcpSeries NetType = iota
	// UdpSeries UDP 系列的不同实现
	UdpSeries = TcpSeries + SeriesInterval

	// SeriesInterval 系列间隔
	SeriesInterval NetType = 1000

	TcpNet  = TcpSeries + 0
	TcpGNet = TcpSeries + 1
)

Variables

View Source
var (
	// ErrUnsupportedNetType 不支持的网络类型
	ErrUnsupportedNetType = errors.New("unsupported net type")
)

Functions

func Connect

func Connect(netType NetType, address string, newAgent core.GetAgent, opts ...core.ClientOption) (core.Client, error)

Connect 使用指定网络类型连接指定端口

func DestroyAll

func DestroyAll()

DestroyAll 摧毁所有服务器客户端

func GetConnNum

func GetConnNum() (num int)

GetConnNum 获取所有连接数

func GetInfo

func GetInfo() map[NetType]*info

GetInfo 获取所有允许的网络类型信息

func Listen

func Listen(netType NetType, address string, newAgent core.GetAgent, opts ...core.ServerOption) (core.Server, error)

Listen 使用指定网络类型监听指定端口

Types

type NetType

type NetType int16

NetType 网络类型

Directories

Path Synopsis
src

Jump to

Keyboard shortcuts

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