tcp

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(listener net.Listener, handler tcp.Handler, closeChan <-chan struct{})

ListenAndServe binds port and handle requests, blocking until close

func ListenAndServeWithSignal

func ListenAndServeWithSignal(cfg *Config, handler tcp.Handler) error

ListenAndServeWithSignal binds port and handle requests, blocking until receive stop signal

Types

type Config

type Config struct {
	Address    string        `yaml:"address"`
	MaxConnect uint32        `yaml:"max-connect"`
	Timeout    time.Duration `yaml:"timeout"`
}

Config stores tcp server properties

type EchoClient added in v1.2.5

type EchoClient struct {
	Conn    net.Conn
	Waiting wait.Wait
}

EchoClient is client for EchoHandler, using for test

func (*EchoClient) Close added in v1.2.5

func (c *EchoClient) Close() error

Close close connection

type EchoHandler

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

EchoHandler echos received line to client, using for test

func MakeEchoHandler

func MakeEchoHandler() *EchoHandler

MakeEchoHandler creates EchoHandler

func (*EchoHandler) Close

func (h *EchoHandler) Close() error

Close stops echo handler

func (*EchoHandler) Handle

func (h *EchoHandler) Handle(ctx context.Context, conn net.Conn)

Handle echos received line to client

Jump to

Keyboard shortcuts

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