udp

package
v0.0.0-...-d0fea3d Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2018 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Overview

refs:

https://en.wikipedia.org/wiki/User_Datagram_Protocol https://en.wikipedia.org/wiki/Stream_Control_Transmission_Protocol https://tools.ietf.org/html/rfc4960 https://en.wikipedia.org/wiki/Datagram_Congestion_Control_Protocol

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout is commont timeout error
	ErrTimeout = errors.New("timeout")
	// ErrConnectionShutdown is a chan single of connection shutdown
	ErrConnectionShutdown = errors.New("connection is shutdown")
	// ErrSegTypeUnknown is the error abount unknown message type
	ErrSegTypeUnknown = errors.New("unknown message type")
)

Functions

func NewClientSocket

func NewClientSocket(conn *net.UDPConn, raddr *net.UDPAddr) (*ClientSocket, *Conn, error)

NewClientSocket create a client socket

Types

type ClientSocket

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

ClientSocket is a UDP implement of Socket

func (*ClientSocket) Accept

func (p *ClientSocket) Accept() (*Conn, error)

Accept wait the new client connection incoming

func (*ClientSocket) Close

func (p *ClientSocket) Close() error

TODO: add lock

type Conn

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

Conn is a UDP implement of es.Conn

func (*Conn) Close

func (c *Conn) Close() error

Close close this connection

func (*Conn) LocalAddr

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

LocalAddr get the address of local endpoint

func (*Conn) Ping

func (c *Conn) Ping() (time.Duration, error)

Ping is used to measure the RTT response time

func (*Conn) Read

func (c *Conn) Read(p []byte) (n int, err error)

func (*Conn) RecvMsg

func (c *Conn) RecvMsg() ([]byte, error)

RecvMsg recv a single message

func (*Conn) RemoteAddr

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

RemoteAddr get the address of remote endpoint

func (*Conn) SendMsg

func (c *Conn) SendMsg(message []byte) error

SendMsg send a single message

func (*Conn) String

func (c *Conn) String() string

func (*Conn) Write

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

type SIUInt16Slice

type SIUInt16Slice []uint16

SIUInt16Slice define a uint16 slice sort interface

func (SIUInt16Slice) Len

func (c SIUInt16Slice) Len() int

func (SIUInt16Slice) Less

func (c SIUInt16Slice) Less(i, j int) bool

func (SIUInt16Slice) Swap

func (c SIUInt16Slice) Swap(i, j int)

type ServerSocket

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

ServerSocket is a UDP implement of socket

func NewServerSocket

func NewServerSocket(conn *net.UDPConn) (*ServerSocket, error)

NewServerSocket create a UDPConn

func (*ServerSocket) Accept

func (p *ServerSocket) Accept() (*Conn, error)

Accept wait the new client connection incoming

func (*ServerSocket) Close

func (p *ServerSocket) Close() error

TODO: add lock

Jump to

Keyboard shortcuts

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