|
RADLib
RADical C++ application framework
|
Convenience UDP server built on RADUdpSocket. More...
#include <RADNet.h>
Inheritance diagram for RADNet::RADUdpServer:
Collaboration diagram for RADNet::RADUdpServer:Public Member Functions | |
| RADUdpServer (RADCore::EventLoop &loop) | |
| Creates a UDP server whose events are posted to loop. More... | |
| ~RADUdpServer () | |
| Closes the internal socket. More... | |
| bool | listen (uint16_t port, const std::string &address="0.0.0.0") |
| Starts listening for UDP datagrams on address:port. More... | |
| bool | sendTo (const std::string &address, uint16_t port, const std::vector< uint8_t > &payload) |
| Sends payload from the server socket to address:port. More... | |
| void | close () |
| Stops listening and closes the socket. More... | |
| uint16_t | localPort () const |
| Returns the bound local port, or 0 when unavailable. More... | |
| void | handleDatagram (RADNet::Datagram datagram) |
| Internal handler that forwards datagrams from the owned socket. More... | |
| void | handleError (std::string message) |
| Internal handler that forwards socket errors. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Public Attributes | |
| RADCore::Event< void(RADNet::Datagram) > | datagramReceived |
| Re-emits datagrams received by the internal socket. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Re-emits socket errors from the internal socket. More... | |
Convenience UDP server built on RADUdpSocket.
|
explicit |
Creates a UDP server whose events are posted to loop.
| RADNet::RADUdpServer::~RADUdpServer | ( | ) |
Closes the internal socket.
| void RADNet::RADUdpServer::close | ( | ) |
Stops listening and closes the socket.
| void RADNet::RADUdpServer::handleDatagram | ( | RADNet::Datagram | datagram | ) |
Internal handler that forwards datagrams from the owned socket.
| void RADNet::RADUdpServer::handleError | ( | std::string | message | ) |
Internal handler that forwards socket errors.
| bool RADNet::RADUdpServer::listen | ( | uint16_t | port, |
| const std::string & | address = "0.0.0.0" |
||
| ) |
Starts listening for UDP datagrams on address:port.
| uint16_t RADNet::RADUdpServer::localPort | ( | ) | const |
Returns the bound local port, or 0 when unavailable.
| bool RADNet::RADUdpServer::sendTo | ( | const std::string & | address, |
| uint16_t | port, | ||
| const std::vector< uint8_t > & | payload | ||
| ) |
Sends payload from the server socket to address:port.
| RADCore::Event<void (RADNet::Datagram) > RADNet::RADUdpServer::datagramReceived |
Re-emits datagrams received by the internal socket.
| RADCore::Event<void (std::string) > RADNet::RADUdpServer::errorOccurred |
Re-emits socket errors from the internal socket.