udp

package
v0.0.0-...-9c21ab8 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotInit = 0
	Inited  = 1
	Closed  = 2
)
View Source
const (
	MaxPacketSize     = 65507
	DefaultPacketSize = 1024
)

Variables

View Source
var (
	ChanFullError = errors.New("write chan full")
	InitError     = errors.New("fail to init")
)

Functions

This section is empty.

Types

type AsyncClient

type AsyncClient struct {
	ServerAddr string
	BufferSize int
	MaxTry     int //最多尝试次数
	Processor  processor.Processor
	// contains filtered or unexported fields
}

func (*AsyncClient) Close

func (client *AsyncClient) Close()

func (*AsyncClient) CloseAndWait

func (client *AsyncClient) CloseAndWait()

func (*AsyncClient) Destroy

func (client *AsyncClient) Destroy()

func (*AsyncClient) Start

func (client *AsyncClient) Start() error

func (*AsyncClient) WriteMsg

func (client *AsyncClient) WriteMsg(msg interface{}) error

type BroadcastClient

type BroadcastClient struct {
	TargetAddr string
	TargetPort int
	ListenPort int
}

广播客户端 广播的服务端其实就是普通的服务端

func (*BroadcastClient) Broad

func (bcc *BroadcastClient) Broad(msg []byte, callback func([]byte, net.Addr), timeout time.Duration) error

一个同步的广播

type Client

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

无连接的一次性的client,用于同步处理

func NewClient

func NewClient(addr string, processor processor.Processor) *Client

func (*Client) Close

func (c *Client) Close()

关闭客户端

func (*Client) Push

func (c *Client) Push(msg interface{}) error

直接推送,不看结果

func (*Client) Request

func (c *Client) Request(msg interface{}, timeout time.Duration) (resp interface{}, err error)

同步请求并等待响应

type MsgInfo

type MsgInfo struct {
	Addr net.Addr
	Msg  []byte
}

type ReceivedContext

type ReceivedContext struct {
	Addr   net.Addr
	Server *Server
}

type Server

type Server struct {
	Addr       string
	BufferSize int
	Processor  processor.Processor
	MaxTry     int
	// contains filtered or unexported fields
}

func (*Server) Close

func (server *Server) Close()

func (*Server) CloseAndWait

func (server *Server) CloseAndWait()

func (*Server) Start

func (server *Server) Start()

func (*Server) WriteMsg

func (server *Server) WriteMsg(msg interface{}, addr net.Addr) error

Jump to

Keyboard shortcuts

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