utp

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: MIT Imports: 23 Imported by: 0

README

go-libutp

GoDoc CircleCI Go Report Card Appveyor Status

This is a Go wrapper for libutp.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnClosed = errors.New("closed")
)
View Source
var Logger = log.New(os.Stderr, "go-libutp: ", log.LstdFlags|log.Lshortfile)

Functions

func WriteStatus

func WriteStatus(w io.Writer)

Types

type Conn

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

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Connect

func (c *Conn) Connect(ctx context.Context, network, addr string) error

Connect an unconnected Conn (obtained through Socket.NewConn).

func (*Conn) LocalAddr

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

func (*Conn) OnError

func (c *Conn) OnError(f func(error))

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) SetWriteBufferLen

func (c *Conn) SetWriteBufferLen(len int)

func (*Conn) SetWriteDeadline

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

func (*Conn) Write

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

func (*Conn) WriteBufferLen

func (c *Conn) WriteBufferLen() int

type FirewallCallback

type FirewallCallback func(net.Addr) bool

type Option

type Option = C.int
const (
	LogNormal   Option = C.UTP_LOG_NORMAL
	LogMtu      Option = C.UTP_LOG_MTU
	LogDebug    Option = C.UTP_LOG_DEBUG
	SendBuffer  Option = C.UTP_SNDBUF
	RecvBuffer  Option = C.UTP_RCVBUF
	TargetDelay Option = C.UTP_TARGET_DELAY

	TimedOut = C.UTP_ETIMEDOUT
)

type Socket

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

func NewSocket

func NewSocket(network, addr string) (*Socket, error)

func (*Socket) Accept

func (s *Socket) Accept() (net.Conn, error)

func (*Socket) Addr

func (s *Socket) Addr() net.Addr

func (*Socket) Close

func (s *Socket) Close() error

func (*Socket) Dial

func (s *Socket) Dial(addr string) (net.Conn, error)

func (*Socket) DialContext

func (s *Socket) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

Passing an empty network will use the network of the Socket's listener.

func (*Socket) DialTimeout

func (s *Socket) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)

func (*Socket) LocalAddr

func (s *Socket) LocalAddr() net.Addr

func (*Socket) NewConn

func (s *Socket) NewConn() (*Conn, error)

func (*Socket) ReadBufferLen

func (s *Socket) ReadBufferLen() int

func (*Socket) ReadFrom

func (s *Socket) ReadFrom(b []byte) (n int, addr net.Addr, err error)

func (*Socket) SetDeadline

func (s *Socket) SetDeadline(t time.Time) error

func (*Socket) SetFirewallCallback

func (s *Socket) SetFirewallCallback(f FirewallCallback)

func (*Socket) SetOption

func (s *Socket) SetOption(opt Option, val int) int

func (*Socket) SetReadDeadline

func (s *Socket) SetReadDeadline(t time.Time) error

func (*Socket) SetWriteBufferLen

func (s *Socket) SetWriteBufferLen(len int)

func (*Socket) SetWriteDeadline

func (s *Socket) SetWriteDeadline(t time.Time) error

func (*Socket) WriteBufferLen

func (s *Socket) WriteBufferLen() int

func (*Socket) WriteTo

func (s *Socket) WriteTo(b []byte, addr net.Addr) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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