netutil

package
v0.0.0-...-53103c5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnReceiveMessage

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

func ConnSendMessage

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

func IsSameSegmentIP

func IsSameSegmentIP(ip1, ip2 string, bc int) bool

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 RandPort

func RandPort() int

RandPort returns a random port number

func TCPRandListen

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

func UDPRandListen

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

Types

type PortBitmap

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

func NewPortBitmap

func NewPortBitmap() *PortBitmap

NewPortBitmap initializes a PortBitmap with a size based on the maximum port number.

func (*PortBitmap) ClearPort

func (pb *PortBitmap) ClearPort(port int) error

ClearPort clears the port as unused in the bitmap.

func (*PortBitmap) GetUsedPorts

func (pb *PortBitmap) GetUsedPorts() []int

GetUsedPorts returns a list of all used ports.

func (*PortBitmap) IsPortSet

func (pb *PortBitmap) IsPortSet(port int) (bool, error)

IsPortSet checks if the port is used in the bitmap.

func (*PortBitmap) SetPort

func (pb *PortBitmap) SetPort(port int) error

SetPort sets the port as used in the bitmap.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳