protocommon

package
v0.0.0-...-ece3ee3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package protocommon contains shared elements between ADC and NMDC connections.

Index

Constants

View Source
const ReStrIP = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"

ReStrIP is the regex to parse an IPv4.

View Source
const ReStrNick = "[^\\$ \\|\n]+"

ReStrNick is the regex to parse a nickname.

View Source
const ReStrPort = "[0-9]{1,5}"

ReStrPort is the regex to parse a port.

Variables

View Source
var ErrorTerminated = fmt.Errorf("terminated")

ErrorTerminated is raised when the connection is terminated.

Functions

This section is empty.

Types

type BaseConn

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

BaseConn is the base connection used by DC protocols.

func NewBaseConn

func NewBaseConn(logLevel log.Level,
	remoteLabel string,
	nconn net.Conn,
	applyReadTimeout bool,
	applyWriteTimeout bool,
	msgDelim byte,
) *BaseConn

NewBaseConn allocates a BaseConn.

func (*BaseConn) BinaryMode

func (c *BaseConn) BinaryMode() bool

BinaryMode returns the binary mode.

func (*BaseConn) Close

func (c *BaseConn) Close() error

Close closes the connection.

func (*BaseConn) DisableWriterZlib

func (c *BaseConn) DisableWriterZlib() error

DisableWriterZlib disables zlib on writings.

func (*BaseConn) EnableReaderZlib

func (c *BaseConn) EnableReaderZlib() error

EnableReaderZlib enables zlib on readings.

func (*BaseConn) EnableWriterZlib

func (c *BaseConn) EnableWriterZlib() error

EnableWriterZlib enables zlib on writings.

func (*BaseConn) LogLevel

func (c *BaseConn) LogLevel() log.Level

LogLevel returns the log level.

func (*BaseConn) ReadBinary

func (c *BaseConn) ReadBinary() ([]byte, error)

ReadBinary reads binary data.

func (*BaseConn) ReadMessage

func (c *BaseConn) ReadMessage() (string, error)

ReadMessage reads a message.

func (*BaseConn) RemoteLabel

func (c *BaseConn) RemoteLabel() string

RemoteLabel returns the remote label.

func (*BaseConn) SetBinaryMode

func (c *BaseConn) SetBinaryMode(val bool)

SetBinaryMode sets the binary mode.

func (*BaseConn) SetSyncMode

func (c *BaseConn) SetSyncMode(val bool)

SetSyncMode sets the sync mode.

func (*BaseConn) Write

func (c *BaseConn) Write(in []byte)

Write writes a message in asynchronous mode.

func (*BaseConn) WriteSync

func (c *BaseConn) WriteSync(in []byte) error

WriteSync writes a message in sync mode.

type MsgBinary

type MsgBinary struct {
	Content []byte
}

MsgBinary is a binary message.

type MsgDecodable

type MsgDecodable interface{}

MsgDecodable is implemented by all decodable messages.

type MsgEncodable

type MsgEncodable interface{}

MsgEncodable is implemented by all encodable messages.

Jump to

Keyboard shortcuts

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