gudp

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBindTwice = fmt.Errorf("bind twice")
View Source
var ErrNotUDPAddr = fmt.Errorf("not udp addr")

Functions

This section is empty.

Types

type Channel

type Channel struct {
	channel.DefaultNetChannel
}

Channel represents a UDP client channel implementation

func (*Channel) UnsafeConnect

func (c *Channel) UnsafeConnect(localAddr net.Addr, remoteAddr net.Addr) error

UnsafeConnect establishes a UDP connection to the remote address Unlike TCP, UDP is connectionless, but this creates a connected UDP socket

type MockUdpChannel

type MockUdpChannel struct {
	channel.MockNetChannel
}

MockUdpChannel is a mock implementation of UDP Channel It embeds MockNetChannel to provide proper mock inheritance

func NewMockUdpChannel

func NewMockUdpChannel() *MockUdpChannel

NewMockUdpChannel creates a new MockUdpChannel instance

func (*MockUdpChannel) UnsafeConnect

func (m *MockUdpChannel) UnsafeConnect(localAddr net.Addr, remoteAddr net.Addr) error

UnsafeConnect mocks the UnsafeConnect method with UDP address validation

type MockUdpServerChannel

type MockUdpServerChannel struct {
	channel.MockServerChannel
	// contains filtered or unexported fields
}

MockUdpServerChannel is a mock implementation of UDP ServerChannel It embeds MockServerChannel to provide proper mock inheritance

func NewMockUdpServerChannel

func NewMockUdpServerChannel() *MockUdpServerChannel

NewMockUdpServerChannel creates a new MockUdpServerChannel instance

func (*MockUdpServerChannel) IsActive

func (m *MockUdpServerChannel) IsActive() bool

IsActive mocks the IsActive method

func (*MockUdpServerChannel) UnsafeAccept

func (m *MockUdpServerChannel) UnsafeAccept() (channel.Channel, channel.Future)

UnsafeAccept mocks the UnsafeAccept method

func (*MockUdpServerChannel) UnsafeBind

func (m *MockUdpServerChannel) UnsafeBind(localAddr net.Addr) error

UnsafeBind mocks the UnsafeBind method with UDP binding logic

func (*MockUdpServerChannel) UnsafeClose

func (m *MockUdpServerChannel) UnsafeClose() error

UnsafeClose mocks the UnsafeClose method

type ServerChannel

type ServerChannel struct {
	channel.DefaultNetServerChannel
	// contains filtered or unexported fields
}

ServerChannel represents a UDP server channel implementation

func (*ServerChannel) IsActive

func (c *ServerChannel) IsActive() bool

IsActive returns whether the UDP server is currently active

func (*ServerChannel) UnsafeAccept

func (c *ServerChannel) UnsafeAccept() (channel.Channel, channel.Future)

UnsafeAccept for UDP servers - since UDP is connectionless, this creates a virtual channel that represents communication with a specific remote address

func (*ServerChannel) UnsafeBind

func (c *ServerChannel) UnsafeBind(localAddr net.Addr) error

UnsafeBind binds the UDP server to the specified local address

func (*ServerChannel) UnsafeClose

func (c *ServerChannel) UnsafeClose() error

UnsafeClose closes the UDP server connection

type UDPClientConn

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

UDPClientConn represents a virtual connection to a specific UDP client This allows UDP to work with the existing channel framework

func (*UDPClientConn) Close

func (c *UDPClientConn) Close() error

Close implements net.Conn interface for UDP client connections

func (*UDPClientConn) LocalAddr

func (c *UDPClientConn) LocalAddr() net.Addr

LocalAddr implements net.Conn interface for UDP client connections

func (*UDPClientConn) Read

func (c *UDPClientConn) Read(b []byte) (n int, err error)

Read implements net.Conn interface for UDP client connections

func (*UDPClientConn) RemoteAddr

func (c *UDPClientConn) RemoteAddr() net.Addr

RemoteAddr implements net.Conn interface for UDP client connections

func (*UDPClientConn) SetDeadline

func (c *UDPClientConn) SetDeadline(t time.Time) error

SetDeadline implements net.Conn interface for UDP client connections

func (*UDPClientConn) SetReadDeadline

func (c *UDPClientConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn interface for UDP client connections

func (*UDPClientConn) SetWriteDeadline

func (c *UDPClientConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn interface for UDP client connections

func (*UDPClientConn) Write

func (c *UDPClientConn) Write(b []byte) (n int, err error)

Write implements net.Conn interface for UDP client connections

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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