net

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package net implements DTLS specific networking primitives. NOTE: this package is an adaptation of pion/transport/packetio that allows for storing a remote address alongside each packet in the buffer and implements relevant methods of net.PacketConn. If possible, the updates made in this repository will be reflected back upstream. If not, it is likely that this will be moved to a public package in this repository.

This package was migrated from pion/transport/packetio at https://github.com/pion/transport/commit/6890c795c807a617c054149eee40a69d7fdfbfdb

Index

Constants

View Source
const MaxInboundDatagramSize = 65535

MaxInboundDatagramSize is the largest complete datagram DTLS will accept.

Variables

ErrTimeout indicates that deadline was reached before operation could be completed.

Functions

func IsShortBuffer

func IsShortBuffer(err error) bool

IsShortBuffer reports whether a datagram exceeded the receive buffer.

Types

type AddrPacket

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

AddrPacket is a packet payload and the associated remote address from which it was received.

type PacketBuffer

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

PacketBuffer is a circular buffer for network packets. Each slot in the buffer contains the remote address from which the packet was received, as well as the packet data.

func NewPacketBuffer

func NewPacketBuffer() *PacketBuffer

NewPacketBuffer creates a new PacketBuffer with default buffer size.

func NewPacketBufferWithSize

func NewPacketBufferWithSize(bufSize int) *PacketBuffer

NewPacketBufferWithSize creates a new PacketBuffer with a given buffer size. If the size is 0 (default), the ring buffer is unbounded and will grow indefinitely.

func (*PacketBuffer) Close

func (b *PacketBuffer) Close() error

Close closes the buffer, allowing unread packets to be read, but erroring on any new writes.

func (*PacketBuffer) ReadFrom

func (b *PacketBuffer) ReadFrom(packet []byte) (n int, addr net.Addr, err error)

ReadFrom reads a single packet from the buffer, or blocks until one is available.

func (*PacketBuffer) SetReadDeadline

func (b *PacketBuffer) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline for the buffer.

func (*PacketBuffer) WriteTo

func (b *PacketBuffer) WriteTo(pkt []byte, addr net.Addr) (int, error)

WriteTo writes a single packet to the buffer. The supplied address will remain associated with the packet.

Directories

Path Synopsis
Package udp implements DTLS specific UDP networking primitives.
Package udp implements DTLS specific UDP networking primitives.

Jump to

Keyboard shortcuts

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