suft

package
v0.0.0-...-358fdb2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2016 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Millisecond = 1e6

Variables

View Source
var (
	ErrIOTimeout        error = &TimeoutError{}
	ErrUnknown                = errors.New("Unknown error")
	ErrInexplicableData       = errors.New("Inexplicable data")
	ErrTooManyAttempts        = errors.New("Too many attempts to connect")
)

Functions

func NewTimerChan

func NewTimerChan(d int64) <-chan byte

func Now

func Now() int64

func NowNS

func NowNS() int64

func StartWatch

func StartWatch(s string) *watch

Types

type Conn

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

func NewConn

func NewConn(e *Endpoint, dest *net.UDPAddr, id connID) *Conn

func (*Conn) Close

func (c *Conn) Close() (err error)

active close: 1 <- send fin-W: closeW()

before sending, ensure all outQ items has beed sent out and all of them has been acked.

2 -> wait to recv ack{fin-W}

then trigger closeR, including send fin-R and wait to recv ack{fin-R}

passive close: -> fin:

if outQ is not empty then self-spin wait.
if outQ empty, send ack{fin-W} then goto closeW().

func (*Conn) IsClosed

func (c *Conn) IsClosed() bool

func (*Conn) LocalAddr

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

func (*Conn) PrintState

func (c *Conn) PrintState()

func (*Conn) Read

func (c *Conn) Read(buf []byte) (nr int, err error)

should not call this function concurrently.

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(data []byte) (nr int, err error)

should not call this function concurrently.

type Endpoint

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

func NewEndpoint

func NewEndpoint(p *Params) (*Endpoint, error)

func (*Endpoint) Accept

func (e *Endpoint) Accept() (net.Conn, error)

net.Listener

func (*Endpoint) Addr

func (e *Endpoint) Addr() net.Addr

net.Listener

func (*Endpoint) Close

func (e *Endpoint) Close() error

net.Listener

func (*Endpoint) Dial

func (e *Endpoint) Dial(addr string) (*Conn, error)

func (*Endpoint) Listen

func (e *Endpoint) Listen() *Conn

func (*Endpoint) ListenTimeout

func (e *Endpoint) ListenTimeout(tmo int64) *Conn

tmo in MS

type Params

type Params struct {
	LocalAddr      string
	Bandwidth      int64
	Mtu            int
	IsServ         bool
	FastRetransmit bool
	FlatTraffic    bool
	EnablePprof    bool
	Stacktrace     bool
	Debug          int
}

type TimeoutError

type TimeoutError struct{}

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

func (*TimeoutError) Temporary

func (e *TimeoutError) Temporary() bool

func (*TimeoutError) Timeout

func (e *TimeoutError) Timeout() bool

Jump to

Keyboard shortcuts

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