DUNE: Uniform Navigational Environment  2019.02.0
DUNE::Network::UDPSocket Class Reference

Detailed Description

UDP Socket.

Public Member Functions

 UDPSocket (void)
 
 ~UDPSocket (void)
 
void enableBroadcast (bool value)
 
void setMulticastTTL (uint8_t ttl=1)
 
void setMulticastLoop (bool loopback=true)
 
void joinMulticastGroup (Address group, Address itf=Address::Any)
 
void bind (uint16_t port=0, Address add=Address::Any, bool reuse=true)
 
void connect (const Address &addr, uint16_t port)
 
size_t write (const uint8_t *buffer, size_t size, const Address &addr, uint16_t port)
 
size_t read (uint8_t *buffer, size_t size, Address *addr=NULL, uint16_t *port=NULL)
 
- Public Member Functions inherited from DUNE::IO::Handle
virtual ~Handle (void)
 
size_t write (const uint8_t *data, size_t length)
 
size_t write (const char *data, size_t length)
 
size_t writeString (const char *cstr)
 
size_t read (uint8_t *data, size_t length)
 
size_t read (char *data, size_t length)
 
size_t readString (char *bfr, size_t length)
 
void flush (void)
 
void flushInput (void)
 
void flushOutput (void)
 
NativeHandle getNative (void) const
 

Additional Inherited Members

- Protected Member Functions inherited from DUNE::IO::Handle
virtual void doFlushInput (void)
 
virtual void doFlushOutput (void)
 
virtual void doFlush (void)
 

Constructor & Destructor Documentation

DUNE::Network::UDPSocket::UDPSocket ( void  )

Create an unbound UDP socket.

References DUNE::NotImplemented.

DUNE::Network::UDPSocket::~UDPSocket ( void  )

Destroy an UDP socket.

Member Function Documentation

void DUNE::Network::UDPSocket::bind ( uint16_t  port = 0,
Address  add = Address::Any,
bool  reuse = true 
)

Assign a name to a socket.

References DUNE::Utils::ByteCopy::toBE(), and DUNE::Network::Address::toInteger().

void DUNE::Network::UDPSocket::connect ( const Address addr,
uint16_t  port 
)
inline
void DUNE::Network::UDPSocket::enableBroadcast ( bool  value)
void DUNE::Network::UDPSocket::joinMulticastGroup ( Address  group,
Address  itf = Address::Any 
)
size_t DUNE::Network::UDPSocket::read ( uint8_t *  buffer,
size_t  size,
Address addr = NULL,
uint16_t *  port = NULL 
)

Receive an UDP datagram, retrieving the address of the source host.

Parameters
bufferdestination buffer.
sizedestination buffer length.
addrsystem specific host address.
portsystem specific host port.

References DUNE::Utils::ByteCopy::fromBE().

void DUNE::Network::UDPSocket::setMulticastLoop ( bool  loopback = true)
void DUNE::Network::UDPSocket::setMulticastTTL ( uint8_t  ttl = 1)
size_t DUNE::Network::UDPSocket::write ( const uint8_t *  buffer,
size_t  size,
const Address addr,
uint16_t  port 
)

Send an UDP datagram to a host.

Parameters
bufferbuffer to send.
sizebuffer length.
addrsystem specific host address.
portdestination port.

References DUNE::Network::Address::str(), DUNE::Utils::ByteCopy::toBE(), and DUNE::Network::Address::toInteger().

Collaboration diagram for DUNE::Network::UDPSocket:
Collaboration graph