soc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package soc has utilities for working with sockets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPermanentNetErr

func IsPermanentNetErr(err error) bool

IsPermanentNetErr returns true if the error is not a temporary net.Error.

func Read

func Read(conn net.Conn, freeMemory *MemPool, toBeDeserialized chan *Data)

Read reads a socket sending the read data to toBeDeserialized. This should be run in it's own go routine.

Types

type Data

type Data struct {
	Buf []byte
	Err error
	// contains filtered or unexported fields
}

Data is the bytes & error that were read from a socket. When data's bytes are no longer used data must be released.

func (*Data) Release

func (d *Data) Release()

Release frees the underlying array to be reused.

type MemPool

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

MemPool is a pool of allocated memory slabs.

func NewMemPool

func NewMemPool(slabCount, slabSize int) *MemPool

NewMemPool returns a new MemPool.

func (*MemPool) Acquire

func (p *MemPool) Acquire() []byte

Acquire returns a memory slab. The returned slab is owned by the caller. The caller must Release() the slab to the pool when the slab is no longer in use.

func (*MemPool) Release

func (p *MemPool) Release(buf []byte)

Release returns ownership of a slab to the pool.

Jump to

Keyboard shortcuts

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