net

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

github.com/whatap/golib/net

Index

Constants

View Source
const (
	UDP_READ_MAX                    = 64 * 1024
	UDP_PACKET_BUFFER               = 64 * 1024
	UDP_PACKET_BUFFER_CHUNKED_LIMIT = 63 * 1024
	UDP_PACKET_CHANNEL_MAX          = 1024
	UDP_PACKET_FLUSH_TIMEOUT        = 10 * 1000

	UDP_PACKET_HEADER_SIZE = 9
	// typ pos 0
	UDP_PACKET_HEADER_TYPE_POS = 0
	// ver pos 1
	UDP_PACKET_HEADER_VER_POS = 1
	// len pos 5
	UDP_PACKET_HEADER_LEN_POS = 5

	UDP_PACKET_SQL_MAX_SIZE = 32768
)

Variables

This section is empty.

Functions

func GetWhatapHosts

func GetWhatapHosts(host string, portStr string) []string

func UdpShutdown

func UdpShutdown()

Types

type EmptyTcpClient

type EmptyTcpClient struct{}

Emtyp TcpClient , use without nil check

func (*EmptyTcpClient) Close

func (tc *EmptyTcpClient) Close() error

func (*EmptyTcpClient) Connect

func (tc *EmptyTcpClient) Connect() error

func (*EmptyTcpClient) Send

func (tc *EmptyTcpClient) Send(p pack.Pack, opts ...TcpClientOption) error

func (*EmptyTcpClient) SendFlush

func (tc *EmptyTcpClient) SendFlush(p pack.Pack, flush bool, opts ...TcpClientOption) error

type Initializer

type Initializer interface {
	Init() error
}

type TcpClient

type TcpClient interface {
	Connect() error
	Send(p pack.Pack, opts ...TcpClientOption) error
	SendFlush(p pack.Pack, flush bool, opts ...TcpClientOption) error
	Close() error
}

type TcpClientConfig added in v0.0.15

type TcpClientConfig struct {
	License    string
	Priority   bool
	SecureFlag byte
}

type TcpClientOption added in v0.0.15

type TcpClientOption interface {
	Apply(conf *TcpClientConfig)
}

func WithLicense added in v0.0.15

func WithLicense(license string) TcpClientOption

func WithPriority added in v0.0.15

func WithPriority(b bool) TcpClientOption

func WithSecureFlag added in v0.0.15

func WithSecureFlag(flag byte) TcpClientOption

type TcpSend

type TcpSend struct {
	Flag  byte
	Pack  pack.Pack
	Flush bool
	Opts  []TcpClientOption
}

type UdpClient

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

func GetUdpClient

func GetUdpClient() *UdpClient

func (*UdpClient) AddCount added in v0.0.15

func (this *UdpClient) AddCount(packCount, chanCount, sendCount, flushErrCount, errCount int, reset bool)

func (*UdpClient) Close

func (this *UdpClient) Close()

func (*UdpClient) GetLocalAddr

func (this *UdpClient) GetLocalAddr() net.Addr

func (*UdpClient) Send

func (this *UdpClient) Send(p udp.UdpPack)

func (*UdpClient) SendRelay

func (this *UdpClient) SendRelay(p pack.Pack, flush bool)

func (*UdpClient) Shutdown

func (this *UdpClient) Shutdown()

type UdpClientConfig added in v0.0.15

type UdpClientConfig struct {
	Log logger.Logger

	Timeout        time.Duration
	Debug          bool
	NetUdpHost     string
	NetUdpPort     int
	Server         string
	UseQueue       bool
	ConfigObserver *config.ConfigObserver
	// contains filtered or unexported fields
}

func (*UdpClientConfig) ApplyConfig added in v0.0.15

func (udpConfig *UdpClientConfig) ApplyConfig(m map[string]string)

type UdpData

type UdpData struct {
	Type  byte
	Ver   int32
	Data  []byte
	Flush bool
}

type WhatapTcpServerInfo

type WhatapTcpServerInfo struct {
	License string
	Hosts   []string
	Pcode   int64
	Oid     int32
}

func NewWhatapTcpServerInfo

func NewWhatapTcpServerInfo(license, host, portStr, pcode, oname string) *WhatapTcpServerInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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