packetbuffer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 4 Imported by: 0

Documentation

Overview

Package packetbuffer implements functions for the manipulation of byte slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PacketBuffer

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

PacketBuffer encapsulates a packet connection and implements the io.Reader interface.

func New

func New(conn net.PacketConn, size int) *PacketBuffer

New creates a packet buffer with specific packet connection and size.

func (*PacketBuffer) Close

func (pb *PacketBuffer) Close()

Close closes this buffer and releases resource.

func (*PacketBuffer) CurrentPacketAddr

func (pb *PacketBuffer) CurrentPacketAddr() net.Addr

CurrentPacketAddr returns current packet's remote address.

func (*PacketBuffer) Next

func (pb *PacketBuffer) Next() error

Next is used to distinguish continuous logic reads. It indicates that the reading on current packet has finished. If there remains data unconsumed, Next returns an error and discards the remaining data.

func (*PacketBuffer) Read

func (pb *PacketBuffer) Read(p []byte) (n int, err error)

Read reads data from the packet. Continuous reads cannot cross between multiple packet only if Close is called.

Jump to

Keyboard shortcuts

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