netw

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte    = 1
	Uint16  = 2
	Uint32  = 4
	Uint64  = 8
	Uint    = 8
	Int8    = 1
	Int16   = 2
	Int32   = 4
	Int64   = 8
	Int     = 8
	Float32 = 4
	Float64 = 8
)

Size stores byte sizes of types

Variables

View Source
var ByteType = reflect.TypeOf(byte(0))

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Data []byte

	Failed bool
	// contains filtered or unexported fields
}

Buffer si for marshaling Data into bites

func (*Buffer) Advance

func (b *Buffer) Advance(add int) bool

Advance shifts a Buffer cursor by value and reports if operation failed (true if failed)

func (*Buffer) Bool

func (b *Buffer) Bool() bool

Bool reads bool from Buffer

func (*Buffer) Byte

func (b *Buffer) Byte() byte

Byte reads byte from Buffer

func (*Buffer) Clear

func (b *Buffer) Clear()

Clear puts buffer to its default value, except Data, that is just truncated to 0 len

func (*Buffer) Finished

func (b *Buffer) Finished() bool

Finished returns whether Buffers cursor is at the end

func (*Buffer) Float32

func (b *Buffer) Float32() float32

Float32 reads float32 from Buffer

func (*Buffer) Float64

func (b *Buffer) Float64() float64

Float64 reads float64 from Buffer

func (*Buffer) Int

func (b *Buffer) Int() int

Int reads int from Buffer

func (*Buffer) Int16

func (b *Buffer) Int16() int16

Int16 reads int16 from Buffer

func (*Buffer) Int32

func (b *Buffer) Int32() int32

Int32 reads int32 from Buffer

func (*Buffer) Int64

func (b *Buffer) Int64() int64

Int64 reads int64 from Buffer

func (*Buffer) PutBool

func (b *Buffer) PutBool(input bool)

PutBool puts bool to Buffer

func (*Buffer) PutFloat32

func (b *Buffer) PutFloat32(input float32) error

PutFloat32 writes float32 to Buffer

func (*Buffer) PutFloat64

func (b *Buffer) PutFloat64(input float64) error

PutFloat64 writes float64 to Buffer

func (*Buffer) PutInt

func (b *Buffer) PutInt(input int)

PutInt writes int to Buffer

func (*Buffer) PutInt16

func (b *Buffer) PutInt16(input int16)

PutInt16 writes int16 to Buffer

func (*Buffer) PutInt32

func (b *Buffer) PutInt32(input int32)

PutInt32 writes int32 to Buffer

func (*Buffer) PutInt64

func (b *Buffer) PutInt64(input int64)

PutInt64 writes int64 to Buffer

func (*Buffer) PutString

func (b *Buffer) PutString(input string)

PutString writes string to byteArray

func (*Buffer) PutUint

func (b *Buffer) PutUint(input uint)

PutUint writes uint to Buffer

func (*Buffer) PutUint16

func (b *Buffer) PutUint16(input uint16)

PutUint16 writes uint16 to Buffer

func (*Buffer) PutUint32

func (b *Buffer) PutUint32(input uint32)

PutUint32 writes uint32 to Buffer

func (*Buffer) PutUint64

func (b *Buffer) PutUint64(input uint64)

PutUint64 writes uint64 to Buffer

func (*Buffer) PutVec

func (b *Buffer) PutVec(input mat.Vec)

func (*Buffer) String

func (b *Buffer) String() string

String reads string from Buffer

func (*Buffer) Uint

func (b *Buffer) Uint() uint

Uint reads uint from Buffer

func (*Buffer) Uint16

func (b *Buffer) Uint16() uint16

Uint16 reads uint16 from Buffer

func (*Buffer) Uint32

func (b *Buffer) Uint32() uint32

Uint32 reads uint32 from Buffer

func (*Buffer) Uint64

func (b *Buffer) Uint64() uint64

Uint64 reads uint64 from Buffer

func (*Buffer) Vec

func (b *Buffer) Vec() mat.Vec

type Reader

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

Reader handles splitting of incoming packets into separate Buffers, assuming that Buffers were put together by Builder

func (*Reader) Read

func (r *Reader) Read(conn net.Conn) (b Buffer, err error)

Read reads one buffer from connection

func (*Reader) Recycle

func (r *Reader) Recycle(bs ...Buffer)

Recycle gives Buffer back to Reader so it can reuse it in next read

type Writer

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

Writer writes data to connection in a way that Reader can read it on other side

func (*Writer) Write

func (w *Writer) Write(conn net.Conn, data []byte) (n int, err error)

Write writes to builder, this never fails and always writes all data

Jump to

Keyboard shortcuts

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