|
RADLib
RADical C++ application framework
|
Event-loop integrated UDP socket. More...
#include <RADNet.h>
Inheritance diagram for RADNet::RADUdpSocket:
Collaboration diagram for RADNet::RADUdpSocket:Public Member Functions | |
| RADUdpSocket (RADCore::EventLoop &loop) | |
| Creates a UDP socket whose events are posted to loop. More... | |
| ~RADUdpSocket () | |
| Closes the socket and unregisters it from the reactor. More... | |
| bool | bind (uint16_t port, const std::string &address="0.0.0.0") |
| Binds to address:port. Use port 0 to request an ephemeral port. More... | |
| bool | sendTo (const std::string &address, uint16_t port, const std::vector< uint8_t > &payload) |
| Sends payload to address:port. More... | |
| void | close () |
| Closes the UDP file descriptor if open. More... | |
| bool | isOpen () const |
| Returns true when the socket currently owns an open descriptor. More... | |
| uint16_t | localPort () const |
| Returns the bound local port, or 0 when unavailable. 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 |
| Raised on the owning RADCore event loop when a datagram arrives. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised when bind, send, receive, or reactor setup fails. More... | |
Event-loop integrated UDP socket.
|
explicit |
Creates a UDP socket whose events are posted to loop.
| RADNet::RADUdpSocket::~RADUdpSocket | ( | ) |
Closes the socket and unregisters it from the reactor.
| bool RADNet::RADUdpSocket::bind | ( | uint16_t | port, |
| const std::string & | address = "0.0.0.0" |
||
| ) |
Binds to address:port. Use port 0 to request an ephemeral port.
| void RADNet::RADUdpSocket::close | ( | ) |
Closes the UDP file descriptor if open.
| bool RADNet::RADUdpSocket::isOpen | ( | ) | const |
Returns true when the socket currently owns an open descriptor.
| uint16_t RADNet::RADUdpSocket::localPort | ( | ) | const |
Returns the bound local port, or 0 when unavailable.
| bool RADNet::RADUdpSocket::sendTo | ( | const std::string & | address, |
| uint16_t | port, | ||
| const std::vector< uint8_t > & | payload | ||
| ) |
Sends payload to address:port.
| RADCore::Event<void (RADNet::Datagram) > RADNet::RADUdpSocket::datagramReceived |
Raised on the owning RADCore event loop when a datagram arrives.
| RADCore::Event<void (std::string) > RADNet::RADUdpSocket::errorOccurred |
Raised when bind, send, receive, or reactor setup fails.