udp

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-udp

This library aims to provide cross-platform connection-oriented and connection-less ECN-capable UDP transport for other applications, such as QUIC and KCP connections.

Credits

Much of the code has been imported from quic-go and pion's UDP implementation and modified to meet the needs in other projects such as go-muxedsocket.

Code from quic-go is licensed under MIT license. Code from pion/transport is licensed under MIT license.

License

MIT

Documentation

Overview

Package conn provides a connection-oriented listener over a UDP PacketConn

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(network string, laddr *net.UDPAddr, raddr *net.UDPAddr) (types.PacketConn, error)

func Listen

func Listen(network string, laddr *net.UDPAddr) (types.SuperConn, error)

Listen creates a new listener using default ListenConfig.

func WrapConnectedConn

func WrapConnectedConn(rawConn types.RawConn, dc *ConnConfig) (types.PacketConn, error)

func WrapListenConn

func WrapListenConn(rawConn types.RawConn, lc *ListenConfig) (types.SuperConn, error)

func WrapUnconnectedConn

func WrapUnconnectedConn(rawConn types.RawConn, rAddr net.Addr, dc *ConnConfig) (types.PacketConn, error)

Types

type Conn

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

Conn augments a connection-oriented connection over a UDP PacketConn.

func (*Conn) Capabilities

func (c *Conn) Capabilities() types.ConnCapabilities

func (*Conn) Close

func (c *Conn) Close() error

Close closes the conn and releases any Read calls.

func (*Conn) LocalAddr

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

LocalAddr implements net.Conn.LocalAddr.

func (*Conn) Read

func (c *Conn) Read(p []byte, oob []byte) (int, int, types.ECN, error)

Read reads from c into p.

func (*Conn) RemoteAddr

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

RemoteAddr implements net.Conn.RemoteAddr.

func (*Conn) SetDeadline

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

SetDeadline implements net.Conn.SetDeadline.

func (*Conn) SetReadDeadline

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

SetReadDeadline implements net.Conn.SetDeadline.

func (*Conn) SetWriteDeadline

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

SetWriteDeadline implements net.Conn.SetDeadline.

func (*Conn) Write

func (c *Conn) Write(p []byte, oob []byte, gsoSize int, ecn types.ECN) (n int, oobN int, err error)

Write writes len(p) bytes from p to the DTLS connection.

type ConnConfig

type ConnConfig struct {
	// ReadBufferSize sets the size of the operating system's
	// receive buffer associated with the dialed connection.
	// The only time this is effective is when a super-connection
	// is being created.
	ReadBufferSize int

	// WriteBufferSize sets the size of the operating system's
	// send buffer associated with the connection.
	// The only time this is effective is when a super-connection
	// is being created.
	WriteBufferSize int

	// WriteIntervals sets the duration that takes the connection to
	// automatically flush the buffers. If set to zero, buffering
	// will be disabled.
	WriteInterval time.Duration
}

ConnConfig stores options for dialing an address or received connections.

func (*ConnConfig) Dial

func (dc *ConnConfig) Dial(network string, laddr *net.UDPAddr, raddr *net.UDPAddr) (types.PacketConn, error)

type ListenConfig

type ListenConfig struct {
	// Backlog defines the maximum length of the queue of pending
	// connections. It is equivalent of the backlog argument of
	// POSIX listen function.
	// If a connection request arrives when the queue is full,
	// the request will be silently discarded, unlike TCP.
	// Set zero to use default value 128 which is same as Linux default.
	Backlog int

	// AcceptFilter determines whether the new conn should be made for
	// the incoming packet. If not set, any packet creates new conn.
	AcceptFilter func([]byte) bool

	ConnConfig
}

ListenConfig stores options for listening to an address.

func (*ListenConfig) Listen

func (lc *ListenConfig) Listen(network string, laddr *net.UDPAddr) (types.SuperConn, error)

Listen creates a new listener based on the ListenConfig.

type SingleAddrConn

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

func (*SingleAddrConn) Capabilities

func (c *SingleAddrConn) Capabilities() types.ConnCapabilities

func (*SingleAddrConn) Close

func (c *SingleAddrConn) Close() error

func (*SingleAddrConn) LocalAddr

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

func (*SingleAddrConn) Read

func (c *SingleAddrConn) Read(p []byte, oob []byte) (dataN int, oobN int, ecn types.ECN, err error)

func (*SingleAddrConn) RemoteAddr

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

func (*SingleAddrConn) SetDeadline

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

func (*SingleAddrConn) SetReadDeadline

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

func (*SingleAddrConn) SetWriteDeadline

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

func (*SingleAddrConn) Write

func (c *SingleAddrConn) Write(p []byte, oob []byte, gsoSize int, ecn types.ECN) (dataN int, oobN int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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