network

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseEvent

type CloseEvent struct{}

type ManagedConnection

type ManagedConnection struct {
	net.Conn
	Events *ManagedConnectionEvents
	// contains filtered or unexported fields
}

ManagedConnection provides a wrapper for a net.Conn to be used together with events.

func NewManagedConnection

func NewManagedConnection(conn net.Conn) *ManagedConnection

func (*ManagedConnection) BytesRead

func (mc *ManagedConnection) BytesRead() uint64

BytesRead returns the total number of bytes read.

func (*ManagedConnection) BytesWritten

func (mc *ManagedConnection) BytesWritten() uint64

BytesWritten returns the total number of bytes written.

func (*ManagedConnection) Close

func (mc *ManagedConnection) Close() (err error)

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*ManagedConnection) Read

func (mc *ManagedConnection) Read(p []byte) (int, error)

func (*ManagedConnection) SetReadTimeout

func (mc *ManagedConnection) SetReadTimeout(d time.Duration) error

func (*ManagedConnection) SetTimeout

func (mc *ManagedConnection) SetTimeout(d time.Duration) error

func (*ManagedConnection) SetWriteTimeout

func (mc *ManagedConnection) SetWriteTimeout(d time.Duration) error

func (*ManagedConnection) Write

func (mc *ManagedConnection) Write(p []byte) (int, error)

type ManagedConnectionEvents

type ManagedConnectionEvents struct {
	ReceiveData *event.Event[*ReceivedDataEvent]
	Close       *event.Event[*CloseEvent]
	Error       *event.Event[error]
}

type ReceivedDataEvent

type ReceivedDataEvent struct {
	Data []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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