netctx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package netctx wraps common net interfaces using context.Context.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosing = errors.New("use of closed network connection")

ErrClosing is returned on Write to closed connection.

Functions

func Pipe

func Pipe() (Conn, Conn)

Pipe creates piped pair of Conn.

Types

type Conn

type Conn interface {
	Reader
	Writer
	io.Closer
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	Conn() net.Conn
}

Conn is a wrapper of net.Conn using context.Context.

func NewConn

func NewConn(netConn net.Conn) Conn

NewConn creates a new Conn wrapping given net.Conn.

type PacketConn

type PacketConn interface {
	ReaderFrom
	WriterTo
	io.Closer
	LocalAddr() net.Addr
	Conn() net.PacketConn
}

PacketConn is a wrapper of net.PacketConn using context.Context.

func NewPacketConn

func NewPacketConn(pconn net.PacketConn) PacketConn

NewPacketConn creates a new PacketConn wrapping the given net.PacketConn.

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

ReadWriter is a composite of ReadWriter.

type Reader

type Reader interface {
	ReadContext(context.Context, []byte) (int, error)
}

Reader is an interface for context controlled reader.

type ReaderFrom

type ReaderFrom interface {
	ReadFromContext(context.Context, []byte) (int, net.Addr, error)
}

ReaderFrom is an interface for context controlled packet reader.

type Writer

type Writer interface {
	WriteContext(context.Context, []byte) (int, error)
}

Writer is an interface for context controlled writer.

type WriterTo

type WriterTo interface {
	WriteToContext(context.Context, []byte, net.Addr) (int, error)
}

WriterTo is an interface for context controlled packet writer.

Jump to

Keyboard shortcuts

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