Core Library 1.7.0.0 Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.

Public Member Functions | Private Member Functions | Private Attributes | List of all members
core_lib::asio::udp::MulticastSender Class Referencefinal

A general purpose multicast sender. More...

`#include <MulticastSender.h>`

## Public Member Functions
| MulticastSender ()=delete
| Default constructor - deleted.
| MulticastSender (boost_iocontext_t &ioContext, const defs::connection_t &multicastConnection, const std::string &interfaceAddress="", bool enableLoopback=true, eMulticastTTL ttl=eMulticastTTL::sameSubnet, size_t sendBufferSize=DEFAULT_UDP_BUF_SIZE)
| Initialisation constructor. More...
| MulticastSender (const defs::connection_t &multicastConnection, const std::string &interfaceAddress="", bool enableLoopback=true, eMulticastTTL ttl=eMulticastTTL::sameSubnet, size_t sendBufferSize=DEFAULT_UDP_BUF_SIZE)
| Initialisation constructor. More...
| MulticastSender (const MulticastSender &)=delete
| Copy constructor - deleted.
MulticastSender & | operator= (const MulticastSender &)=delete
| Copy assignment operator - deleted.
| MulticastSender (MulticastSender &&)=delete
| Move constructor - deleted.
MulticastSender & | operator= (MulticastSender &&)=delete
| Move assignment operator - deleted.
| ~MulticastSender ()=default
| Default destructor.
defs::connection_t | MulticastConnection () const
| Retrieve multicast connection details. More...
std::string | InterfaceAddress () const
| Retrieve interface IP address. More...
bool | SendMessage (const defs::char_buffer_t &message)
| Send a message buffer to the receiver. More...

## Private Member Functions
void | CreateMulticastSocket (bool enableLoopback, eMulticastTTL ttl, size_t sendBufferSize)
| Create multicast socket. More...
bool | SyncSendTo (const defs::char_buffer_t &message)
| Synchronised send to method. More...

## Private Attributes
std::unique_ptr< IoContextThreadGroup > | m_ioThreadGroup {}
| I/O context thread group.
defs::connection_t | m_multicastConnection {}
| Multicast connection details.
std::string | m_interfaceAddress {}
| Interface IP address of outgoing network adaptor.
boost_udp_t::endpoint | m_multicastEndpoint {}
| Multicast receiver end-point.
boost_udp_t::socket | m_socket
| Multicast socket.

## Detailed Description

A general purpose multicast sender.

This class forms the underpinnings of the MulticastTypedSender class.

## Constructor & Destructor Documentation

## ◆ MulticastSender() [1/2]

core_lib::asio::udp::MulticastSender::MulticastSender | ( | boost_iocontext_t & | ioContext,
|  | const defs::connection_t & | multicastConnection,
|  | const std::string & | interfaceAddress = `""`,
|  | bool | enableLoopback = `true`,
|  | eMulticastTTL | ttl = `eMulticastTTL::sameSubnet`,
|  | size_t | sendBufferSize = `DEFAULT_UDP_BUF_SIZE`
| ) |  |

Initialisation constructor.

Parameters

  [in] | ioContext | - External boost IO context to manage ASIO.
  [in] | multicastConnection | - Connection object describing target multicast group address and port.
  [in] | interfaceAddress | - Optional interface IP address for outgoing network messages.
  [in] | enableLoopback | - Optional allow multicasts to loopback on same adapter.
  [in] | ttl | - Optional time-to-live for multicast messages.
  [in] | sendBufferSize | - Socket send option to control send 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.

## ◆ MulticastSender() [2/2]

core_lib::asio::udp::MulticastSender::MulticastSender | ( | const defs::connection_t & | multicastConnection,
|  | const std::string & | interfaceAddress = `""`,
|  | bool | enableLoopback = `true`,
|  | eMulticastTTL | ttl = `eMulticastTTL::sameSubnet`,
|  | size_t | sendBufferSize = `DEFAULT_UDP_BUF_SIZE`
| ) |  |
| explicit

Initialisation constructor.

Parameters

  [in] | multicastConnection | - Connection object describing target multicast group address and port.
  [in] | interfaceAddress | - Optional interface IP address for outgoing network messages.
  [in] | enableLoopback | - Optional allow multicasts to loopback on same adapter.
  [in] | ttl | - Optional time-to-live for multicast messages.
  [in] | sendBufferSize | - Socket send option to control send 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.

## Member Function Documentation

## ◆ CreateMulticastSocket()

void core_lib::asio::udp::MulticastSender::CreateMulticastSocket | ( | bool | enableLoopback,
|  | eMulticastTTL | ttl,
|  | size_t | sendBufferSize
| ) |  |
| private

Create multicast socket.

Parameters

  [in] | enableLoopback | - Allow multicasts to loopback on same adapter.
  [in] | ttl | - Time-to-live for multicast messages.
  [in] | sendBufferSize | - Send buffer size.

## ◆ InterfaceAddress()

auto core_lib::asio::udp::MulticastSender::InterfaceAddress | ( |  | ) | const

Retrieve interface IP address.

Returns
  - Interface IP address.

## ◆ MulticastConnection()

auto core_lib::asio::udp::MulticastSender::MulticastConnection | ( |  | ) | const

Retrieve multicast connection details.

Returns
  - Connection object describing target multicast group address and port.

## ◆ SendMessage()

bool core_lib::asio::udp::MulticastSender::SendMessage | ( | const defs::char_buffer_t & | message | ) |

Send a message buffer to the receiver.

Parameters

  [in] | message | - The message buffer.

Returns
  Returns the success state of the send as a boolean.

## ◆ SyncSendTo()

bool core_lib::asio::udp::MulticastSender::SyncSendTo | ( | const defs::char_buffer_t & | message | ) |
| private

Synchronised send to method.

Parameters

  [in] | message | - Message buffer to send.

Returns
  True if successfully sent, false otherwise.

The documentation for this class was generated from the following files:

- D:/Projects/CoreLibrary/Include/Asio/MulticastSender.h
- D:/Projects/CoreLibrary/Source/Asio/MulticastSender.cpp