TraveSim Adapters  0.1
Protobuf adapters for TraveSim project
multicast_receiver.hpp
Go to the documentation of this file.
1 /**
2  * @file multicast_receiver.hpp
3  *
4  * @author Lucas Haug <lucas.haug@thuneratz.org>
5  * @author Lucas Schneider <lucas.schneider@thuneratz.org>
6  *
7  * @brief Receiver data using UDP in multicast mode
8  *
9  * @date 04/2021
10  *
11  * @copyright MIT License - Copyright (c) 2021 ThundeRatz
12  */
13 
15 
16 #ifndef __MULTICAST_RECEIVER_H__
17 #define __MULTICAST_RECEIVER_H__
18 
19 namespace travesim {
20 namespace udp {
21 /**
22  * @brief Receiver class using UDP in multicast mode
23  */
25  public Receiver {
26  public:
27  /**
28  * @brief Construct a new Multicast Receiver object
29  *
30  * @param multicast_address Multicas group address
31  * @param multicast_port Multicast group port
32  * @param receiver_address Receiver address, has a filtering role, setting
33  * where the data may be received
34  *
35  * @note The multicast addresses must be in the range 224.0.0.0 through
36  * 239.255.255.255, see [IPv4 Multicast Address Space Registry]
37  * (https://www.iana.org/assignments/multicast-addresses/multicast-addresses.xhtml)
38  * or the [RFC1112](https://tools.ietf.org/html/rfc1112) for more informations.
39  */
40  MulticastReceiver(const std::string multicast_address, const short multicast_port,
41  const std::string receiver_address);
42 
43  /**
44  * @brief Construct a new Multicast Receiver object
45  *
46  * @param multicast_address Multicas group address
47  * @param multicast_port Multicast group port
48  *
49  * @note Use multicast address as listen address
50  *
51  * @note The multicast addresses must be in the range 224.0.0.0 through
52  * 239.255.255.255, see [IPv4 Multicast Address Space Registry]
53  * (https://www.iana.org/assignments/multicast-addresses/multicast-addresses.xhtml)
54  * or the [RFC1112](https://tools.ietf.org/html/rfc1112) for more informations.
55  */
56  MulticastReceiver(const std::string multicast_address, const short multicast_port);
57 
58  /**
59  * @brief Destroy the Multicast Receiver object
60  */
62 
63  /**
64  * @brief Set the multicast address
65  *
66  * @param multicast_address Multicast group address in a string
67  *
68  * @warning reset() must be called after changing the address
69  *
70  * @note The multicast addresses must be in the range 224.0.0.0 through
71  * 239.255.255.255, see [IPv4 Multicast Address Space Registry]
72  * (https://www.iana.org/assignments/multicast-addresses/multicast-addresses.xhtml)
73  * or the [RFC1112](https://tools.ietf.org/html/rfc1112) for more informations.
74  */
75  void set_multicast_address(const std::string multicast_address);
76 
77  private:
78  boost::asio::ip::address multicast_address;
79 
80  /**
81  * @brief Open the socket with the desired options
82  */
83  void open_socket();
84 
85  /**
86  * @brief Close the socket
87  */
88  void close_socket();
89 };
90 } // namespace udp
91 } // namespace travesim
92 
93 #endif // __MULTICAST_RECEIVER_H__
~MulticastReceiver()
Destroy the Multicast Receiver object.
void set_multicast_address(const std::string multicast_address)
Set the multicast address.
Receiver class using UDP in multicast mode.
MulticastReceiver(const std::string multicast_address, const short multicast_port, const std::string receiver_address)
Construct a new Multicast Receiver object.
Receiver data using UDP.
boost::asio::ip::address multicast_address
Receiver class using UDP.
Definition: receiver.hpp:25
void close_socket()
Close the socket.
void open_socket()
Open the socket with the desired options.