tcpudp

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectTCP

func ConnectTCP(host string, port int, deadline time.Duration) (*net.TCPConn, error)

ConnectTCP - connects to the specified address

func ConnectUDP

func ConnectUDP(host string, port int, deadline time.Duration) (*net.UDPConn, error)

ConnectUDP - connects to the specified address

func ReadTCP

func ReadTCP(connection *net.TCPConn, bufferSize int) (string, error)

ReadTCP - read from the connection

func WriteTCP

func WriteTCP(connection *net.TCPConn, payload string, endAfter bool) error

WriteTCP - writes to the connection

func WriteUDP

func WriteUDP(connection *net.UDPConn, payload string) error

WriteUDP - writes to the connection

Types

type MessageData

type MessageData struct {
	Message string
	Date    time.Time
	Host    string
	Port    int
}

MessageData - the message data received

type ServerConfiguration

type ServerConfiguration struct {
	Host               string
	MessageChannelSize int
	ReadBufferSize     int
}

ServerConfiguration - common configuration

type TCPConfiguration

type TCPConfiguration struct {
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	ResponseString string
	ServerConfiguration
}

TCPConfiguration - the tcp server configuration

type TCPServer

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

TCPServer - the tcp server

func NewTCPServer

func NewTCPServer(configuration *TCPConfiguration, start bool) (*TCPServer, int)

NewTCPServer - creates a new telnet server on a random port

func (*TCPServer) GetErrors

func (ts *TCPServer) GetErrors() []error

GetErrors - get asynchronous errors

func (*TCPServer) MessageChannel

func (ts *TCPServer) MessageChannel() <-chan MessageData

MessageChannel - reads from the message channel

func (*TCPServer) Start

func (ts *TCPServer) Start()

Start - starts the server to receive connections

func (*TCPServer) Stop

func (ts *TCPServer) Stop() error

Stop - stops the server

type UDPServer

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

UDPServer - the udp server

func NewUDPServer

func NewUDPServer(configuration *ServerConfiguration, start bool) (*UDPServer, int)

NewUDPServer - creates a new udp server on a random port

func (*UDPServer) GetErrors

func (us *UDPServer) GetErrors() []error

GetErrors - get asynchronous errors

func (*UDPServer) MessageChannel

func (us *UDPServer) MessageChannel() <-chan MessageData

MessageChannel - reads from the message channel

func (*UDPServer) Start

func (us *UDPServer) Start()

Start - starts the server to receive connections

func (*UDPServer) Stop

func (us *UDPServer) Stop() error

Stop - stops the server

Jump to

Keyboard shortcuts

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