reader

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrLostData

type ErrLostData struct {
	Lost int
}

ErrLostData is returned when there is a gap in the TCP stream due to missing or late packets. It is returned only if LossErrors is set to true, and only once for each gap. Successive read attempts will succeed, proceeding at the next available data.

func (ErrLostData) Error

func (e ErrLostData) Error() string

type TCPReaderStream

type TCPReaderStream struct {
	LossErrors bool
	// contains filtered or unexported fields
}

TCPReaderStream implements tcpassembly.Stream and model.Reader

func New

func New() *TCPReaderStream

New creates a new TCPReaderStream.

func NewPair

func NewPair() (client, server *TCPReaderStream)

NewPair creates an associated pair of TCPReaderStreams.

func (*TCPReaderStream) Close

func (r *TCPReaderStream) Close() error

Close releases held resources, and discards any remaining data. After Close is called any buffers returned from ReadN or ReadLine are invalid.

func (*TCPReaderStream) Discard

func (r *TCPReaderStream) Discard(n int) (discarded int, err error)

Discard skips the next n bytes, returning the number of bytes discarded.

If Discard skips fewer than n bytes, it also returns an error.

func (*TCPReaderStream) Peek

func (r *TCPReaderStream) Peek(n int) ([]byte, error)

Peek returns up to n bytes of the next data from r, without advancing the stream.

Peek does not modify the state of r. In particular Peek will not advance past lost data, and will repeatedly return ErrLostData until a Read, ReadN, or ReadLine operation.

func (*TCPReaderStream) Read

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

Read attempts to read sufficient data to fill p. It returns the number of bytes read into p. If EOF is encountered, n will be less than len(p). At EOF, the count will be zero and err will be io.EOF.

func (*TCPReaderStream) ReadLine

func (r *TCPReaderStream) ReadLine() ([]byte, error)

ReadLine returns a single line, not including the end-of-line bytes. The returned buffer is only valid until the next call to ReadN, ReadLine or Close. ReadLine either returns a non-nil line or it returns an error, never both.

The text returned from ReadLine does not include the line end ("\r\n" or "\n"). No indication or error is given if the input ends without a final line end.

func (*TCPReaderStream) ReadN

func (r *TCPReaderStream) ReadN(n int) ([]byte, error)

ReadN returns the next n bytes.

If EOF is encountered before reading n bytes, the available bytes are returned along with ErrUnexpectedEOF.

The returned buffer is only valid until the next call to ReadN, ReadLine or Close.

func (*TCPReaderStream) Reassembled

func (r *TCPReaderStream) Reassembled(reassembly []tcpassembly.Reassembly)

Reassembled buffers stream data for later consumption by this reader. If the buffer fills it is sent to the reader side, blocking if the reader is falling behind.

func (*TCPReaderStream) ReassemblyComplete

func (r *TCPReaderStream) ReassemblyComplete()

ReassemblyComplete sends any buffered stream data to the reader.

Jump to

Keyboard shortcuts

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