socket

package
v3.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package socket provides a pseudo socket

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Pool holds the socket pool

func NewPool

func NewPool() *Pool

NewPool returns a new socket pool

func (*Pool) Close

func (p *Pool) Close()

Close the pool and delete all the sockets

func (*Pool) Get

func (p *Pool) Get(id string) (*Socket, bool)

Get socket from pool

func (*Pool) Release

func (p *Pool) Release(s *Socket)

Release close the socket and delete from pool

type Socket

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

Socket is our pseudo socket for transport.Socket

func New

func New(id string) *Socket

New returns a new pseudo socket which can be used in the place of a transport socket. Messages are sent to the socket via Accept and receives from the socket via Process. SetLocal/SetRemote should be called before using the socket.

func (*Socket) Accept

func (s *Socket) Accept(m *transport.Message) error

Accept passes a message to the socket which will be processed by the call to Recv

func (*Socket) Close

func (s *Socket) Close() error

Close closes the socket

func (*Socket) Local

func (s *Socket) Local() string

Local returns local addr

func (*Socket) Process

func (s *Socket) Process(m *transport.Message) error

Process takes the next message off the send queue created by a call to Send

func (*Socket) Recv

func (s *Socket) Recv(m *transport.Message) error

Recv message from transport

func (*Socket) Remote

func (s *Socket) Remote() string

Remote returns remote addr

func (*Socket) Send

func (s *Socket) Send(m *transport.Message) error

Send message by via transport

func (*Socket) SetLocal

func (s *Socket) SetLocal(l string)

SetLocal sets the local addr

func (*Socket) SetRemote

func (s *Socket) SetRemote(r string)

SetRemote sets the remote addr

Jump to

Keyboard shortcuts

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