A general purpose multicast receiver.
More...
#include <MulticastReceiver.h>
A general purpose multicast receiver.
This class is used as the underpinnings of the SimpleMulticastReceiver class.
◆ MulticastReceiver() [1/2]
Initialisation constructor.
- Parameters
-
| [in] | ioContext | - External boost IO context to manage ASIO. |
| [in] | multicastConnection | - Connection object describing target multicast group address and port. |
| [in] | checkBytesLeftToRead | - Function object capable of decoding the message and computing how many bytes are left until a complete message. |
| [in] | messageReceivedHandler | - Function object capable of handling a received message and dispatching it accordingly. |
| [in] | interfaceAddress | - Optional interface IP address for incoming network messages. |
| [in] | receiveBufferSize | - Optional socket receive option to control receive buffer size. |
Typically use this constructor when managing a pool 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 executed using this thread pool managed by a single IO context. This is the recommended constructor.
◆ MulticastReceiver() [2/2]
Initialisation constructor.
- Parameters
-
| [in] | multicastConnection | - Connection object describing target multicast group address and port. |
| [in] | checkBytesLeftToRead | - Function object capable of decoding the message and computing how many bytes are left until a complete message. |
| [in] | messageReceivedHandler | - Function object capable of handling a received message and dispatching it accordingly. |
| [in] | interfaceAddress | - Optional interface IP address for incoming network messages. |
| [in] | receiveBufferSize | - Optional 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 recommended.
◆ CreateMulticastSocket()
| void core_lib::asio::udp::MulticastReceiver::CreateMulticastSocket |
( |
size_t |
receiveBufferSize | ) |
|
|
private |
Create multicast socket.
- Parameters
-
| [in] | receiveBufferSize | - Receive buffer size. |
◆ InterfaceAddress()
| std::string core_lib::asio::udp::MulticastReceiver::InterfaceAddress |
( |
| ) |
const |
Retrieve interface IP address.
- Returns
- - Interface IP address.
◆ IsClosing()
| bool core_lib::asio::udp::MulticastReceiver::IsClosing |
( |
| ) |
const |
|
private |
Get closing state.
- Returns
- True if closing socket, false otherwise.
◆ MulticastConnection()
Retrieve multicast connection details.
- Returns
- - Connection object describing target multicast group address and port.
◆ ReadComplete()
| void core_lib::asio::udp::MulticastReceiver::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::MulticastReceiver::SetClosing |
( |
bool |
closing | ) |
|
|
private |
Set closing state.
- Parameters
-
| [in] | closing | - Closing socket flag. |
The documentation for this class was generated from the following files: