netutil

package
v0.0.0-...-40131ec Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStreamHandlerNotSet = errors.InternalServer("stream handler not set", "stream handler not set")
)

Functions

func ClientTLSConfig

func ClientTLSConfig() *tls.Config

func ConnReceiveMessage

func ConnReceiveMessage(conn net.Conn, data interface{}) error

func ConnSendMessage

func ConnSendMessage(conn net.Conn, data interface{}) error

func RUDPReceiveAllMessage

func RUDPReceiveAllMessage(conn *reliableUDP.ReliableUDP, timeout time.Duration, msg interface{}) (*net.UDPAddr, error)

func RUDPSendMessage

func RUDPSendMessage(conn *reliableUDP.ReliableUDP, addr string, msg interface{}, timeout time.Duration) error

发送超时时间为timeout,如果timeout为0则默认为4秒

func RUDPSendUnreliableMessage

func RUDPSendUnreliableMessage(conn *reliableUDP.ReliableUDP, addr string, msg interface{}) error

func ServerTLSConfig

func ServerTLSConfig() *tls.Config

func TCPRandListen

func TCPRandListen() (*net.TCPListener, error)

func UDPRandListen

func UDPRandListen() (*net.UDPConn, error)

func UdpReceiveMessage

func UdpReceiveMessage(conn *net.UDPConn, data interface{}) (*net.UDPAddr, error)

func UdpSendByteMessage

func UdpSendByteMessage(conn *net.UDPConn, target *net.UDPAddr, data []byte) error

func UdpSendMessage

func UdpSendMessage(conn *net.UDPConn, target *net.UDPAddr, data interface{}) error

Types

type ReliableUDPServer

type ReliableUDPServer struct {
	UDPConn *net.UDPConn
	// contains filtered or unexported fields
}

func NewReliableUDPServer

func NewReliableUDPServer(udpConn *net.UDPConn) (*ReliableUDPServer, error)

func (*ReliableUDPServer) Close

func (s *ReliableUDPServer) Close() error

Close closes the server

func (*ReliableUDPServer) SetStreamHandler

func (s *ReliableUDPServer) SetStreamHandler(handler ReliableUDPStreamHandler)

SetStreamHandler sets the stream handler

func (*ReliableUDPServer) Start

func (s *ReliableUDPServer) Start() error

Start starts the server

type ReliableUDPStreamHandler

type ReliableUDPStreamHandler = func(conn quic.Connection, stream quic.Stream) error

Jump to

Keyboard shortcuts

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