tcpserver

package
v1.1.22 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCancelled = errors.New("cancelled")
)

Functions

This section is empty.

Types

type ConnectionHandler

type ConnectionHandler func(ctx context.Context, conn net.Conn, userData interface{})

ConnectionHandler is the signature of the handler function Returning an error in the handler exits the ListerAndServe function with that error

type TCPServer

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

TCPServer holds the data for our TCP Server

func (*TCPServer) GetNbAccepted

func (tcpServer *TCPServer) GetNbAccepted() int64

GetNbAccepted returns the number of connections accepted

func (*TCPServer) GetNbGoroutines

func (tcpServer *TCPServer) GetNbGoroutines() int64

GetNbGoroutines returns the number of goroutines currently handling connections

func (*TCPServer) ListerAndServe

func (tcpServer *TCPServer) ListerAndServe(ctx context.Context, address string, handler ConnectionHandler, tlsConfig *tls.Config, userData interface{}) error

ListerAndServe accepts incoming tcp connexions and calls the handler in a new goroutine

func (*TCPServer) Wait

func (tcpServer *TCPServer) Wait()

Wait waits until all the goroutines are finished

Directories

Path Synopsis
sample module

Jump to

Keyboard shortcuts

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