quick

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 8 Imported by: 0

README

a net.Conn compatible lib via QUIC

The initial code is cloned from quic (upstream module github.com/smallnest/quick), but I refactored and updated the code; this fork is published as module github.com/tzrd/quick.

Run the example

Start listening for an incoming QUIC connection

go run example/main.go -s

The server will echo every message received on the connection in uppercase.

Send a message on the QUIC connection:

go run example/main.go -c

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StreamAcceptTimeout = 30 * time.Second

StreamAcceptTimeout bounds how long AcceptContext waits for a newly accepted connection to open its first stream. When it expires the connection is closed with a NO_ERROR code and AcceptContext keeps waiting for the next peer, so a client that never opens a stream cannot stall the listener. A zero or negative value disables the timeout. The value is read once when a listener is created; later changes only affect listeners created afterwards.

Functions

func Dial

func Dial(addr string, tlsConfig *tls.Config, quicConfig *quic.Config) (net.Conn, error)

Dial creates a new QUIC connection it returns once the connection is established and secured with forward-secure keys

func DialContext

func DialContext(ctx context.Context, addr string, tlsConfig *tls.Config, quicConfig *quic.Config) (net.Conn, error)

DialContext creates a new QUIC connection with a context. The returned net.Conn owns its UDP socket; Close releases all resources associated with the connection, including the socket.

func Listen

func Listen(network, laddr string, tlsConfig *tls.Config, quicConfig *quic.Config) (net.Listener, error)

Listen creates a QUIC listener on the given network interface

Types

type Conn

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

Conn is a generic quic connection implements net.Conn.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the stream, sending a FIN to the peer. Data written before Close is still delivered, mirroring the semantics of closing a TCP connection. The QUIC connection itself stays alive until the peer closes it or the idle timeout expires; on the client side the owned UDP socket is released as soon as the QUIC connection ends. It is safe to call Close multiple times; subsequent calls return the result of the first one.

func (*Conn) CloseConn

func (c *Conn) CloseConn() error

CloseConn immediately terminates the QUIC connection with a NO_ERROR code and closes the owned UDP socket on the client side. Unlike Close, data written but not yet transmitted to the network is discarded. It is safe to call CloseConn multiple times.

func (*Conn) LocalAddr

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

LocalAddr returns the local network address.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read implements the Conn Read method.

func (*Conn) RemoteAddr

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

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline

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

SetDeadline sets the read and write deadlines for the QUIC stream. A zero time value disables the deadline.

func (*Conn) SetReadBuffer

func (c *Conn) SetReadBuffer(bytes int) error

SetReadBuffer sets the size of the operating system's receive buffer associated with the connection. On the server side the buffer is shared by all connections served by the same listener.

func (*Conn) SetReadDeadline

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

SetReadDeadline implements the Conn SetReadDeadline method.

func (*Conn) SetWriteBuffer

func (c *Conn) SetWriteBuffer(bytes int) error

SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection. On the server side the buffer is shared by all connections served by the same listener.

func (*Conn) SetWriteDeadline

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

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (*Conn) SyscallConn

func (c *Conn) SyscallConn() (syscall.RawConn, error)

SyscallConn returns a raw network connection. This implements the syscall.Conn interface.

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Write implements the Conn Write method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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