commpipe

package
v0.0.0-...-5c775dd Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFrameSize = 1<<16 - 1

Variables

This section is empty.

Functions

func Handshake

func Handshake(p *Pipe) error

Handshake initiates a handshake request and waits for a response.

func ShakeHand

func ShakeHand(p *Pipe) error

ShakeHand is the inverse of Handshake and shakes the reaching hand.

Types

type Pipe

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

Pipe is a bi-directional communication channel.

func NewPipe

func NewPipe(inp io.Reader, out io.Writer) *Pipe

func (*Pipe) Read

func (p *Pipe) Read(out *TLVFrame) (err error)

func (*Pipe) Write

func (p *Pipe) Write(f *TLVFrame) error

type TLVFrame

type TLVFrame struct {
	Type TLVType
	Size uint64
	Data []byte
}

func (*TLVFrame) ReadFrom

func (f *TLVFrame) ReadFrom(r io.Reader) (n int64, err error)

func (*TLVFrame) WriteTo

func (f *TLVFrame) WriteTo(w io.Writer) (n int64, err error)

type TLVType

type TLVType uint64
const (
	TLVTypeHandshake TLVType = iota + 1
	TLVTypePing
	TLVTypePong
	TLVTypeQuit
	TLVTypeUser
)

type TrackingReader

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

func NewTrackingReader

func NewTrackingReader(rd io.Reader, offset *int64) *TrackingReader

func (*TrackingReader) Offset

func (r *TrackingReader) Offset() int64

func (*TrackingReader) Read

func (r *TrackingReader) Read(p []byte) (n int, err error)

type TrackingWriter

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

func NewTrackingWriter

func NewTrackingWriter(wr io.Writer, offset *int64) *TrackingWriter

func (*TrackingWriter) Offset

func (w *TrackingWriter) Offset() int64

func (*TrackingWriter) Write

func (w *TrackingWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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