...

Package sockettest

import "github.com/mdlayher/socket/internal/sockettest"
Overview
Index

Overview ▾

Package sockettest implements net.Listener and net.Conn types based on *socket.Conn for use in the package's tests.

type Conn

A Conn is a net.Conn which can be extended with context support.

type Conn struct {
    Conn *socket.Conn
    // contains filtered or unexported fields
}

func Dial

func Dial(ctx context.Context, addr net.Addr, cfg *socket.Config) (*Conn, error)

Dial creates an IPv4 or IPv6 TCP net.Conn backed by a *socket.Conn with optional configuration.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) CloseRead

func (c *Conn) CloseRead() error

func (*Conn) CloseWrite

func (c *Conn) CloseWrite() error

func (*Conn) Context

func (c *Conn) Context(ctx context.Context) *Conn

func (*Conn) LocalAddr

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

func (*Conn) Read

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

func (*Conn) RemoteAddr

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

func (*Conn) SetDeadline

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

func (*Conn) SetReadDeadline

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

func (*Conn) SetWriteDeadline

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

func (*Conn) Write

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

type Listener

A Listener is a net.Listener which can be extended with context support.

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

func FileListener

func FileListener(f *os.File) (*Listener, error)

FileListener creates an IPv6 TCP net.Listener backed by a *socket.Conn from the input file.

func Listen

func Listen(port int, cfg *socket.Config) (*Listener, error)

Listen creates an IPv6 TCP net.Listener backed by a *socket.Conn on the specified port with optional configuration. Context ctx will be passed to accept and accepted connections.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) Context

func (l *Listener) Context(ctx context.Context) *Listener