conn

package
v0.0.0-...-cf12e39 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCP = "tcp"
	UDP = "udp"
)

Variables

View Source
var DefaultTimeOut = 10 * time.Second

Functions

func InitTrafficChannel

func InitTrafficChannel(up, down func(int64, int))

Types

type BufferConn

type BufferConn struct {
	IConn
	// contains filtered or unexported fields
}

func (*BufferConn) Flush

func (c *BufferConn) Flush() (n int, err error)

func (*BufferConn) Write

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

type DefaultConn

type DefaultConn struct {
	net.Conn
	ID       int64
	RecordID int64
	Network  string
	// contains filtered or unexported fields
}

func (*DefaultConn) Close

func (c *DefaultConn) Close() error

func (*DefaultConn) Context

func (c *DefaultConn) Context() context.Context

func (*DefaultConn) Flush

func (c *DefaultConn) Flush() (int, error)

func (*DefaultConn) GetID

func (c *DefaultConn) GetID() int64

func (*DefaultConn) GetNetwork

func (c *DefaultConn) GetNetwork() string

func (*DefaultConn) GetRecordID

func (c *DefaultConn) GetRecordID() int64

func (*DefaultConn) Read

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

func (*DefaultConn) SetContext

func (c *DefaultConn) SetContext(ctx context.Context)

func (*DefaultConn) SetRecordID

func (c *DefaultConn) SetRecordID(id int64)

func (*DefaultConn) Write

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

type IConn

type IConn interface {
	net.Conn
	GetID() int64
	GetRecordID() int64
	SetRecordID(id int64)
	GetNetwork() string
	Flush() (int, error)
	Context() context.Context
	SetContext(context.Context)
}

func BufferDecorate

func BufferDecorate(c IConn) (IConn, error)

缓冲装饰

func DefaultDecorate

func DefaultDecorate(c net.Conn, network string) (IConn, error)

func DefaultDecorateForTls

func DefaultDecorateForTls(c net.Conn, network string, id int64) (IConn, error)

func DirectConn

func DirectConn(network, host string) (IConn, error)

func NewDefaultConn

func NewDefaultConn(conn net.Conn, network string) (IConn, error)

func RealTimeDecorate

func RealTimeDecorate(c IConn) (IConn, error)

实时写出

func TimerDecorate

func TimerDecorate(c IConn, rto, wto time.Duration) (IConn, error)

超时装饰

func TrafficDecorate

func TrafficDecorate(c IConn) (IConn, error)

type RealTimeFlush

type RealTimeFlush struct {
	IConn
}

func (*RealTimeFlush) Write

func (r *RealTimeFlush) Write(b []byte) (n int, err error)

type TimerConn

type TimerConn struct {
	IConn
	ReadTimeOut  time.Duration
	WriteTimeOut time.Duration
}

func (*TimerConn) Read

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

func (*TimerConn) Write

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

type Traffic

type Traffic struct {
	IConn
}

func (*Traffic) Read

func (t *Traffic) Read(b []byte) (n int, err error)

func (*Traffic) Write

func (t *Traffic) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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