udp

package
v0.0.0-...-ad164ee Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Data interface{}
}

Message is a basic serializable message

type MulticastReader

type MulticastReader struct {
	ErrChan <-chan error
	// contains filtered or unexported fields
}

MulticastReader implements NetReader for multicast UDP communication

func NewMulticastReader

func NewMulticastReader(addr string) (*MulticastReader, error)

NewMulticastReader creates a new net struct used for receiving from the given address (hostname:port)

func (*MulticastReader) ReadAddr

func (n *MulticastReader) ReadAddr() string

func (*MulticastReader) StartReceiving

func (n *MulticastReader) StartReceiving(tag string) (<-chan interface{}, error)

StartReceiving starts listening on the Net, and returns a channel which will yield messages when they arrive.

func (*MulticastReader) StopReceiving

func (n *MulticastReader) StopReceiving()

StopReceiving closes channels and stops the receive loop

type NetReader

type NetReader interface {
	StartReceiving(string) (<-chan interface{}, error)
	StopReceiving()
	ReadAddr() string
}

NetReader binds to and continuously reads from the given host and port

type NetWriter

type NetWriter interface {
	Write(data interface{}) error
	WriteAddr() string
}

NetWriter writes packets to the network

type UDPWriter

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

UDPWriter contains methods to write to a udp address (host:port)

func NewUDPWriter

func NewUDPWriter(addr string) (*UDPWriter, error)

NewUDPWriter creates a new writer that writes to the given address (host:port)

func (*UDPWriter) Write

func (u *UDPWriter) Write(data interface{}) error

write opens a writes a UDP datagram to the configured address and port.

func (*UDPWriter) WriteAddr

func (u *UDPWriter) WriteAddr() string

WriteAddr returns the address written to

type UniReader

type UniReader struct {
	ErrChan <-chan error
	// contains filtered or unexported fields
}

UniReader implements NetReader for unicast UDP communication

func NewUniReader

func NewUniReader(addr string) (*UniReader, error)

NewUniReader creates a new net struct used for receiving from the given address (hostname:port)

func (*UniReader) ReadAddr

func (n *UniReader) ReadAddr() string

ReadAddr returns the address being read from (host:port)

func (*UniReader) StartReceiving

func (n *UniReader) StartReceiving(tag string) (<-chan interface{}, error)

StartReceiving starts listening on the Net, and returns a channel which will yield messages when they arrive.

func (*UniReader) StopReceiving

func (n *UniReader) StopReceiving()

StopReceiving closes channels and stops the receive loop

Jump to

Keyboard shortcuts

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