A general purpose UDP receiver.
More...
#include <UdpReceiver.h>
A general purpose UDP receiver.
This class is used as the underpinnings of the SimpleUdpReceiver class.
◆ UdpReceiver() [1/2]
Initialisation constructor.
- Parameters
-
| [in] | ioContext | - External boost IO context to manage ASIO. |
| [in] | listenPort | - Our listen port for all detected networks. |
| [in] | checkBytesLeftToRead | - Function object capable of decoding the message and computing how many bytes are left until a complete message. |
| [in] | messageReceivedHandler | - Function object cpable of handling a received message and disptaching it accordingly. |
| [in] | receiveOptions | - Socket receive option to control the use of broadcasts/unicast. |
| [in] | receiveBufferSize | - Socket receive option to control receive buffer size. |
Typically use this constructor when managing a bool of threads using an instance of core_lib::asio::IoContextThreadGroup in your application to manage a pool of std::threads. This means you can use a single thread pool and all ASIO operations will be exectued using this thread pool managed by a single IO context. This is the recommended constructor.
◆ UdpReceiver() [2/2]
Initialisation constructor.
- Parameters
-
| [in] | listenPort | - Our listen port for all detected networks. |
| [in] | checkBytesLeftToRead | - Function object capable of decoding the message and computing how many bytes are left until a complete message. |
| [in] | messageReceivedHandler | - Function object cpable of handling a received message and disptaching it accordingly. |
| [in] | receiveOptions | - Socket receive option to control the use of broadcasts/unicast. |
| [in] | receiveBufferSize | - Socket receive option to control receive buffer size. |
This constructor does not require an external IO context to run instead it creates its own IO context object along with its own thread. For very simple cases this version will be fine but in more performance and resource critical situations the external IO context constructor is recommened.
◆ CreateUdpSocket()
| void core_lib::asio::udp::UdpReceiver::CreateUdpSocket |
( |
eUdpOption |
receiveOptions, |
|
|
size_t |
receiveBufferSize |
|
) |
| |
|
private |
Create UDP socket.
- Parameters
-
| [in] | receiveOptions | - UDP receive options. |
| [in] | receiveBufferSize | - Receive buffer size. |
◆ IsClosing()
| bool core_lib::asio::udp::UdpReceiver::IsClosing |
( |
| ) |
const |
|
private |
Get closing state.
- Returns
- True if closing socket, false otherwise.
◆ ListenPort()
| uint16_t core_lib::asio::udp::UdpReceiver::ListenPort |
( |
| ) |
const |
Retrieve this receiver's listen port.
- Returns
- The listen port.
◆ ReadComplete()
| void core_lib::asio::udp::UdpReceiver::ReadComplete |
( |
const boost_sys::error_code & |
error, |
|
|
size_t |
bytesReceived |
|
) |
| |
|
private |
Read completion handler.
- Parameters
-
| [in] | error | - Error code if one has happened. |
| [in] | bytesReceived | - Number of bytes received. |
◆ SetClosing()
| void core_lib::asio::udp::UdpReceiver::SetClosing |
( |
bool |
closing | ) |
|
|
private |
Set closing state.
- Parameters
-
| [in] | closing | - Closing socket flag. |
The documentation for this class was generated from the following files: