gonet

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteAddr = "&remoteAddr"
	LocalAddr  = "&localAddr"
	Middle     = "&middle"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

func (*Context) Close

func (c *Context) Close() error

func (*Context) LocalAddr

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

func (*Context) Read

func (c *Context) Read(b []byte) (n int, err error)

func (*Context) ReadToBytes

func (c *Context) ReadToBytes() (b []byte, err error)

func (*Context) RemoteAddr

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

func (*Context) Write

func (c *Context) Write(b []byte) (n int, err error)

type Dialer

type Dialer struct {
	TcpMultiplex bool

	*Context
	Timeout time.Duration
	// contains filtered or unexported fields
}

func Dial

func Dial(network, addr, laddr string, tcpMultiplex ...bool) (*Dialer, error)

func (Dialer) Add

func (m Dialer) Add(middle MiddleInterface)

func (*Dialer) Dial

func (d *Dialer) Dial(network, addr, laddr string) (err error)

type Listener

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

func Listen

func Listen(network, addr string, tcpMultiplex ...bool) *Listener

func (*Listener) Run

func (l *Listener) Run() error

func (*Listener) SetControl

func (l *Listener) SetControl(f func(network string, address string, c syscall.RawConn) error)

func (*Listener) SetKeepAlive

func (l *Listener) SetKeepAlive(t time.Duration)

type MiddleInterface

type MiddleInterface interface {
	// BeforeReading HandleFunc前调用
	BeforeReading(ctx *Context) error

	// BeforeSend 发送前调用
	BeforeSend(ctx *Context) error
}

type PacketConn

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

func ListenPacket

func ListenPacket(network, addr string, tcpMultiplex ...bool) (*PacketConn, error)

func (*PacketConn) Close

func (p *PacketConn) Close(addr net.Addr) error

func (*PacketConn) ReadAll

func (p *PacketConn) ReadAll() (*Context, error)

func (*PacketConn) ReadToBytes

func (p *PacketConn) ReadToBytes() (data []byte, addr net.Addr, err error)

func (*PacketConn) WriteTo

func (p *PacketConn) WriteTo(b []byte, addr net.Addr) (n int, err error)

Jump to

Keyboard shortcuts

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