Documentation ¶
Index ¶
- Constants
- Variables
- type Connection
- type Listener
- type Logger
- type NetConnection
- func (nc *NetConnection) Cancel()
- func (nc *NetConnection) Close()
- func (nc *NetConnection) IsOpened() bool
- func (nc *NetConnection) NetHandler() net.Conn
- func (nc *NetConnection) Open() error
- func (nc *NetConnection) Parent() Listener
- func (nc *NetConnection) Recv() ([]byte, error)
- func (nc *NetConnection) RecvWait(timeout float64) ([]byte, error)
- func (nc *NetConnection) Send(data []byte) error
- func (bs NetConnection) String() string
- func (bs NetConnection) Type() string
- func (bs NetConnection) Uri() string
- type NetListener
- func (nl *NetListener) IsActive() bool
- func (nl *NetListener) NetHandler() net.Listener
- func (nl *NetListener) SetConnHandler(h func(Connection))
- func (nl *NetListener) Start() error
- func (nl *NetListener) Stop()
- func (bs NetListener) String() string
- func (bs NetListener) Type() string
- func (bs NetListener) Uri() string
- type Options
- type SerialConnection
- func (sc *SerialConnection) Cancel()
- func (sc *SerialConnection) Close()
- func (sc *SerialConnection) IsOpened() bool
- func (sc *SerialConnection) Open() error
- func (sc *SerialConnection) Parent() Listener
- func (sc *SerialConnection) PortHandler() serial.Port
- func (sc *SerialConnection) Recv() ([]byte, error)
- func (sc *SerialConnection) RecvWait(timeout float64) ([]byte, error)
- func (sc *SerialConnection) Send(data []byte) error
- func (bs SerialConnection) String() string
- func (bs SerialConnection) Type() string
- func (bs SerialConnection) Uri() string
- type SerialListener
- func (sl *SerialListener) Close()
- func (sl *SerialListener) IsActive() bool
- func (sl *SerialListener) PortHandler() serial.Port
- func (sl *SerialListener) SetConnHandler(h func(Connection))
- func (sl *SerialListener) Start() error
- func (sl *SerialListener) Stop()
- func (bs SerialListener) String() string
- func (bs SerialListener) Type() string
- func (bs SerialListener) Uri() string
Constants ¶
View Source
const ( ERROR_DELAY = float64(0.5) POLL_INTERVAL = float64(0.2) POLL_CHUNKSIZE = int(1024) POLL_MAXSIZE = int(0) POLL_WAITNULLREAD = false )
View Source
const ( NET_CONNECT_TIMEOUT = float64(10) NET_KEEPALIVE_INTERVAL = float64(30) NET_CONNECTIONS_LIMIT = int(0) )
Variables ¶
View Source
var ( ErrError = errors.New("") ErrUri = fmt.Errorf("%winvalid uri", ErrError) ErrConnection = fmt.Errorf("%wconnection failed", ErrError) ErrClosed = fmt.Errorf("%wconnection closed", ErrError) ErrBreak = fmt.Errorf("%woperation break", ErrError) ErrTimeout = fmt.Errorf("%woperation timeout", ErrError) ErrRead = fmt.Errorf("%wread failed", ErrError) ErrWrite = fmt.Errorf("%wwrite failed", ErrError) )
Define common errors
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { Uri() string Type() string Parent() Listener IsOpened() bool Open() error Close() Cancel() Send([]byte) error Recv() ([]byte, error) RecvWait(float64) ([]byte, error) }
interface representing connection
func NewConnection ¶
func NewConnection( uri string, log *Logger, opts Options) (Connection, error)
create new connection handler
type Listener ¶
type Listener interface { Uri() string Type() string IsActive() bool Start() error Stop() SetConnHandler(func(Connection)) }
interface representing listener
type NetConnection ¶
type NetConnection struct { // connect timeout in sec ConnectTimeout float64 // keepalive interval in sec, use 0 to disable KeepAliveInterval float64 // contains filtered or unexported fields }
Network Connection
func NewNetConnection ¶
func NewNetConnection( uri string, log *Logger, opts Options) (*NetConnection, error)
NewNetConnection creates a new SockClient instance
func (*NetConnection) IsOpened ¶
func (nc *NetConnection) IsOpened() bool
func (*NetConnection) NetHandler ¶
func (nc *NetConnection) NetHandler() net.Conn
func (*NetConnection) Parent ¶
func (nc *NetConnection) Parent() Listener
func (*NetConnection) Recv ¶
func (nc *NetConnection) Recv() ([]byte, error)
Recv data from the socket connection
func (*NetConnection) RecvWait ¶
func (nc *NetConnection) RecvWait(timeout float64) ([]byte, error)
Receives data with a specified timeout from the socket connection
func (*NetConnection) Send ¶
func (nc *NetConnection) Send(data []byte) error
Sends data over the socket connection
type NetListener ¶
type NetListener struct {
// contains filtered or unexported fields
}
Network Listener
func NewNetListener ¶
func NewNetListener( uri string, log *Logger, opts Options) (*NetListener, error)
func (*NetListener) IsActive ¶
func (nl *NetListener) IsActive() bool
func (*NetListener) NetHandler ¶
func (nl *NetListener) NetHandler() net.Listener
func (*NetListener) SetConnHandler ¶
func (nl *NetListener) SetConnHandler(h func(Connection))
func (*NetListener) Start ¶
func (nl *NetListener) Start() error
func (*NetListener) Stop ¶
func (nl *NetListener) Stop()
type SerialConnection ¶
type SerialConnection struct {
// contains filtered or unexported fields
}
Serial Connection
func NewSerialConnection ¶
func NewSerialConnection( uri string, log *Logger, opts Options) (*SerialConnection, error)
func (*SerialConnection) IsOpened ¶
func (sc *SerialConnection) IsOpened() bool
func (*SerialConnection) Open ¶
func (sc *SerialConnection) Open() error
func (*SerialConnection) Parent ¶
func (sc *SerialConnection) Parent() Listener
func (*SerialConnection) PortHandler ¶
func (sc *SerialConnection) PortHandler() serial.Port
func (*SerialConnection) Recv ¶
func (sc *SerialConnection) Recv() ([]byte, error)
Recv data from the serial connection
func (*SerialConnection) RecvWait ¶
func (sc *SerialConnection) RecvWait(timeout float64) ([]byte, error)
Receives data with a specified timeout from the serial connection
func (*SerialConnection) Send ¶
func (sc *SerialConnection) Send(data []byte) error
Sends data over the serial connection
type SerialListener ¶
type SerialListener struct { *SerialConnection // contains filtered or unexported fields }
Serial Listener
func NewSerialListener ¶
func NewSerialListener( uri string, log *Logger, opts Options) (*SerialListener, error)
func (*SerialListener) Close ¶ added in v0.3.11
func (sl *SerialListener) Close()
no close action in listener mode, nust use stop method
func (*SerialListener) IsActive ¶
func (sl *SerialListener) IsActive() bool
func (*SerialListener) PortHandler ¶
func (sl *SerialListener) PortHandler() serial.Port
func (*SerialListener) SetConnHandler ¶
func (sl *SerialListener) SetConnHandler(h func(Connection))
func (*SerialListener) Start ¶
func (sl *SerialListener) Start() error
func (*SerialListener) Stop ¶
func (sl *SerialListener) Stop()
Click to show internal directories.
Click to hide internal directories.