mudp

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 2 Imported by: 0

README

mudp 使用说明

提供基于 github.com/panjf2000/gnet/v2 的简单 UDP 封装:

  • NewServer(addr, handler, opts...):创建 UDP Server(addr 可不带协议,如 :9001
  • Server.Start() / Server.StartAsync() / Server.Stop():生命周期管理
  • SendTo(remote, data):使用标准库发送单个 UDP 包

示例:

# 1. 启动接收端
go run ./mudp/udp_receiver_demo

# 2. 运行发送端(在另一个终端)
go run ./mudp/udp_sender_demo

接收端将打印收到的消息。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OnMessageFunc added in v0.4.0

type OnMessageFunc func(eventName string, data []byte)

type Server added in v0.4.0

type Server struct {
	Port      int
	IP        string
	MultiCore bool
	OnMessage OnMessageFunc
}

func NewServer added in v0.4.0

func NewServer(opt Server) *Server

func (*Server) Start added in v0.4.0

func (c *Server) Start() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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