pingconn

package
v0.0.0-...-df39993 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PingConn

type PingConn struct {
	net.Conn
	// contains filtered or unexported fields
}

PingConn wraps a net.Conn and add ping capabilities to it, including the `WritePing` function and `Read` (which excludes ping packets).

When using this connection, the packets written will contain an initial data: the packet size. When reading, this information is taken into account, but it is not returned to the caller.

Ping messages have a packet size of zero and are produced only when `WritePing` is called. On `Read`, any Ping packet is discarded.

func New

func New(conn net.Conn) *PingConn

New returns a ping connection wrapping the provided net.Conn.

func (*PingConn) Read

func (c *PingConn) Read(p []byte) (int, error)

Read reads content from the underlying connection, discarding any ping messages it finds.

func (*PingConn) Write

func (c *PingConn) Write(p []byte) (int, error)

Write writes provided content to the underlying connection with proper protocol fields.

func (*PingConn) WritePing

func (c *PingConn) WritePing() error

WritePing writes the ping packet to the connection.

type PingTLSConn

type PingTLSConn struct {
	*tls.Conn
	// contains filtered or unexported fields
}

PingTLSConn wraps a tls.Conn and adds ping capabilities to it.

func NewTLS

func NewTLS(conn *tls.Conn) *PingTLSConn

NewTLS returns a ping connection wrapping the provided tls.Conn.

func (*PingTLSConn) Read

func (c *PingTLSConn) Read(p []byte) (int, error)

Read reads content from the underlying connection, discarding any ping messages it finds.

func (*PingTLSConn) Write

func (c *PingTLSConn) Write(p []byte) (int, error)

Write writes provided content to the underlying connection with proper protocol fields.

func (*PingTLSConn) WritePing

func (c *PingTLSConn) WritePing() error

WritePing writes the ping packet to the connection.

Jump to

Keyboard shortcuts

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