kcp

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDataShards   = 10 //FEC前向纠错算法的数据冗余度
	DefaultParityShards = 3  ////FEC前向纠错算法的奇偶校验配置
)

kcp 协议的配置

Variables

This section is empty.

Functions

func AddInheritedFunc

func AddInheritedFunc(fn func([]*Listener, map[string]string))

AddInheritedFunc 平滑重启的时候,会回调该方法,保存fd列表

func DialAddrContext

func DialAddrContext(network string, laddr *net.UDPAddr, raddr string, tlsConf *tls.Config, dataShards, parityShards int) (net.Conn, error)

func GetInheritedFunc

func GetInheritedFunc(fn func() []int)

GetInheritedFunc 如果是平滑重启,可以获取到从父进程继承过来的fd列表

func InheritedListen

func InheritedListen(network, laddr string, tlsConf *tls.Config, dataShards, parityShards int) (net.Listener, error)

InheritedListen 使用kcp协议启动监听,需要先判断是否是继承过来的端口 network: 网络类型,在这里只能是udp协议,但是区分udp,udp4,udp6 laddr: 本地要监听的数据包地址端口 tlsConf: 证书信息 dataShards,parityShards: FEC前向纠错算法的数据冗余度配置,这两个参数决定了fec的冗余度,冗余度越大抗丢包性就越强。

func SetInherited

func SetInherited() error

SetInherited 添加files列表到环境变量,让子进程继承, 1. 只有在reboot使用 2. 不支持windows系统

Types

type Listener

type Listener struct {
	*kcp.Listener
	// contains filtered or unexported fields
}

func Listen

func Listen(conn net.PacketConn, tlsConf *tls.Config, dataShards, parityShards int) (*Listener, error)

func ListenAddr

func ListenAddr(network, addr string, tlsConf *tls.Config, dataShards, parityShards int) (*Listener, error)

func ListenUDPAddr

func ListenUDPAddr(network string, udpAddr *net.UDPAddr, tlsConf *tls.Config, dataShards, parityShards int) (*Listener, error)

func (*Listener) Accept

func (that *Listener) Accept() (net.Conn, error)

func (*Listener) PacketConn

func (that *Listener) PacketConn() net.PacketConn

type UDPSession

type UDPSession = kcp.UDPSession

UDPSession defines a KCP session implemented by UDP

Jump to

Keyboard shortcuts

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