rrserver

package
v0.0.0-...-ea46046 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PT_SIZE          = uint32(512) // packet len in byte
	PT_SIZE_BYTE_LEN = 4           // packet len value in bits
)
View Source
const (
	IP_PROTOCOL       = "ipv4"
	DEFAULT_POOL_SIZE = 10
)

Variables

View Source
var (
	CustomHandleConn = func(c *TCPConnection, packet []byte) {
		logs.Warn("forget rrserver.CustomHandleConn = YourCustomHandleConn in init func?")
	}
)
View Source
var (
	ErrClosed = fmt.Errorf("pool not created or closed")
)

Functions

func SendTCPRequest

func SendTCPRequest(addr string, msg []byte) (error, []byte)

Types

type TCPConnection

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

func NewTCPConnection

func NewTCPConnection(conn net.Conn) *TCPConnection

func (*TCPConnection) Close

func (c *TCPConnection) Close() error

func (*TCPConnection) LocalAddr

func (c *TCPConnection) LocalAddr() string

func (*TCPConnection) Read

func (c *TCPConnection) Read() (error, []byte)

func (*TCPConnection) RemoteAddr

func (c *TCPConnection) RemoteAddr() string

func (*TCPConnection) SetKeepAlive

func (c *TCPConnection) SetKeepAlive(v bool) error

func (*TCPConnection) Write

func (c *TCPConnection) Write(msg []byte) error

type TCPConnectionPool

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

func CreateTCPConnectionPool

func CreateTCPConnectionPool(poolSize int) *TCPConnectionPool

func (*TCPConnectionPool) Add

func (s *TCPConnectionPool) Add(addr string, c *TCPConnection) error

func (*TCPConnectionPool) CloseAll

func (s *TCPConnectionPool) CloseAll(addr string)

func (*TCPConnectionPool) Get

func (s *TCPConnectionPool) Get(addr string) (error, *TCPConnection)

type TCPServer

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

func CreateTCPServer

func CreateTCPServer(inf string, port int) (error, *TCPServer)

func CreateTCPServerByAddr

func CreateTCPServerByAddr(addr string) (error, *TCPServer)

func (*TCPServer) Start

func (s *TCPServer) Start()

Jump to

Keyboard shortcuts

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