udp

package
v0.1.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 7 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 {
	// contains filtered or unexported fields
}

Client 表示一个 UDP 客户端

func NewUDPClient

func NewUDPClient(cfg Config) *Client

NewUDPClient 创建 UDP 客户端

func (*Client) Close

func (c *Client) Close()

Close 关闭 UDP 客户端

func (*Client) Receive

func (c *Client) Receive() ([]byte, error)

Receive 阻塞接收 UDP 消息

func (*Client) Send

func (c *Client) Send(data []byte) error

Send 异步发送 UDP 消息

func (*Client) Start

func (c *Client) Start() error

Start 启动 UDP 客户端

type Config

type Config struct {
	Address       string
	Port          int32
	MaxPacketSize int32
	ReadTimeout   time.Duration
}

Config 配置 UDP 客户端

type Manager

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

Manager 管理多个 Client

func NewUDPManager

func NewUDPManager() *Manager

NewUDPManager 创建管理器

func (*Manager) AddClient

func (m *Manager) AddClient(name string, client *Client)

AddClient 添加客户端

func (*Manager) CloseAll

func (m *Manager) CloseAll()

CloseAll 关闭所有客户端

func (*Manager) GetClient

func (m *Manager) GetClient(name string) (*Client, bool)

GetClient 获取客户端

func (*Manager) RemoveClient

func (m *Manager) RemoveClient(name string)

RemoveClient 删除并关闭客户端

Jump to

Keyboard shortcuts

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