TraveSim Adapters  0.1
Protobuf adapters for TraveSim project
unicast_receiver.cpp
Go to the documentation of this file.
1 /**
2  * @file unicast_receiver.cpp
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 unicast mode
8  *
9  * @date 04/2021
10  *
11  * @copyright MIT License - Copyright (c) 2021 ThundeRatz
12  */
13 
15 
16 namespace travesim {
17 namespace udp {
18 /*****************************************
19  * Public Methods Bodies Definitions
20  *****************************************/
21 
22 UnicastReceiver::UnicastReceiver(std::string receiver_address, short receiver_port) : Receiver(receiver_address,
23  receiver_port) {
24  this->open_socket();
25 };
26 
28  this->close_socket();
29 };
30 
31 /*****************************************
32  * Protected Methods Bodies Definitions
33  *****************************************/
34 
36  this->socket->open(this->receiver_endpoint.protocol());
37 
38  this->socket->set_option(boost::asio::ip::unicast::hops(1));
39  this->socket->bind(this->receiver_endpoint);
40 
41  // Use non blocking for syncronous reading
42  this->socket->non_blocking(true);
43 };
44 } // namespace udp
45 } // namespace travesim
virtual void close_socket()
Close the socket.
Definition: receiver.cpp:128
boost::asio::ip::udp::socket * socket
Definition: receiver.hpp:88
Receiver data using UDP in unicast mode.
void open_socket()
Open the socket with the desired options.
UnicastReceiver(const std::string receiver_address, const short receiver_port)
Construct a new Unicast Receiver object.
boost::asio::ip::udp::endpoint receiver_endpoint
Definition: receiver.hpp:89
~UnicastReceiver()
Destroy the Unicast Receiver object.
Receiver class using UDP.
Definition: receiver.hpp:25