connection

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Connect() error
	IsConnected() bool
	Listen()
	Write(data []byte)
	ReadStringFromConnection() (string, error)
	Disconnect() error
}

type TCPConnection

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

func NewTCPConnection

func NewTCPConnection(serverHost string, serverPort string) TCPConnection

NewTCPConnection creates a new TCP connection to the server provided

func (*TCPConnection) Connect

func (tcpConn *TCPConnection) Connect() error

Connect connects to the tcp server

func (*TCPConnection) Disconnect

func (tcpConn *TCPConnection) Disconnect() error

Disconnect disconnects form the tcp server and closes all internal channels and cancel all internal contexts

func (*TCPConnection) IsConnected

func (tcpConn *TCPConnection) IsConnected() bool

IsConnected gives connection status

func (*TCPConnection) Listen

func (tcpConn *TCPConnection) Listen()

Listen listens to the incoming messages and writes outgoing messages to the connection

func (*TCPConnection) ReadStringFromConnection

func (tcpConn *TCPConnection) ReadStringFromConnection() (string, error)

ReadStringFromConnection is a blocking call that reads from a channel

func (*TCPConnection) Write

func (tcpConn *TCPConnection) Write(data []byte)

Write writes the bytes array to the TCP connection

Jump to

Keyboard shortcuts

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