18 namespace mcast = ip::multicast;
24 :
Base(id, config, context)
64 "BasicASIOTransport::setup:"
65 " No host addresses. Aborting setup.\n");
77 auto addr = ip::address::from_string(addr_parts.first);
78 addresses_.emplace_back(addr, addr_parts.second);
81 "BasicASIOTransport::setup:"
82 " settings address[%d] to %s:%d\n",
83 i,
addresses_.back().address().to_string().c_str(),
86 catch (
const boost::system::system_error& e)
89 "BasicASIOTransport::setup:"
90 " Error parsing address %s: %s\n",
98 "BasicASIOTransport::setup:"
99 " No valid addresses. Aborting setup.\n");
108 catch (
const boost::system::system_error& e)
111 "BasicASIOTransport::setup:"
112 " Error opening sockets: %s\n",
138 asio::socket_base::send_buffer_size send_buffer_option;
139 asio::socket_base::receive_buffer_size receive_buffer_option;
143 socket.get_option(send_buffer_option);
144 int send_buff_size = send_buffer_option.value();
146 socket.get_option(receive_buffer_option);
147 int rcv_buff_size = receive_buffer_option.value();
150 "BasicASIOTransport::setup:"
151 " default socket buff size is send=%d, rcv=%d\n",
152 send_buff_size, rcv_buff_size);
154 if (send_buff_size < tar_buff_size)
157 "BasicASIOTransport::setup:"
158 " setting send buff size to settings.queue_length (%d)\n",
161 send_buffer_option = tar_buff_size;
162 socket.set_option(send_buffer_option);
164 socket.get_option(send_buffer_option);
165 send_buff_size = send_buffer_option.value();
168 "BasicASIOTransport::setup:"
169 " current socket buff size is send=%d, rcv=%d\n",
170 send_buff_size, rcv_buff_size);
173 if (rcv_buff_size < tar_buff_size)
176 "BasicASIOTransport::setup:"
177 " setting rcv buff size to settings.queue_length (%d)\n",
180 receive_buffer_option = tar_buff_size;
181 socket.set_option(receive_buffer_option);
183 socket.get_option(receive_buffer_option);
184 rcv_buff_size = receive_buffer_option.value();
187 "BasicASIOTransport::setup:"
188 " current socket buff size is send=%d, rcv=%d\n",
189 send_buff_size, rcv_buff_size);
192 catch (
const boost::system::system_error& e)
195 "BasicASIOTransport::setup:"
196 " Error setting up sockets: %s\n",
246 "BasicASIOTransport::setup:"
247 " starting %d threads at %f hertz\n",
252 std::stringstream thread_name;
253 thread_name <<
"read";
257 "BasicASIOTransport::setup:"
258 " starting thread %s at %f hertz\n",
259 thread_name.str().c_str(), hertz);
#define madara_logger_log(loggering, level,...)
Fast version of the madara::logger::log method.
void use(ThreadSafeContext &original)
Refer to and use another knowledge base's context.
This class stores variables and their values for use by any entity needing state information in a thr...
logger::Logger & get_logger(void) const
Gets the logger used for information printing.
void terminate(const std::string &name)
Requests a specific thread to terminate.
bool wait(const std::string &name, const knowledge::WaitSettings &ws=knowledge::WaitSettings())
Wait for a specific thread to complete.
void set_data_plane(knowledge::KnowledgeBase &data_plane)
Sets the data plane for new threads.
Base class from which all transports must be derived.
int validate_transport(void)
Validates a transport to indicate it is not shutting down.
QoSTransportSettings settings_
madara::knowledge::ThreadSafeContext & context_
virtual int setup(void)
all subclasses should call this method at the end of its setup
void invalidate_transport(void)
Invalidates a transport to indicate it is shutting down.
virtual int setup_sockets()
threads::Threader read_threads_
threads for reading knowledge updates
virtual int setup_write_socket()
virtual int setup_read_thread(double hertz, const std::string &name)=0
BasicASIOTransport(const std::string &id, madara::knowledge::ThreadSafeContext &context, TransportSettings &config)
virtual int setup_read_socket()
std::vector< udp::endpoint > addresses_
holds all multicast addresses we are sending to
virtual int setup_read_threads()
udp::socket socket_
underlying socket
knowledge::KnowledgeBase knowledge_
knowledge base for threads to use
int setup() override
all subclasses should call this method at the end of its setup
void close() override
Closes this transport.
virtual int setup_socket(udp::socket &socket)
Holds basic transport settings.
bool no_receiving
if true, never receive over transport
std::vector< std::string > hosts
Host information for transports that require it.
uint32_t queue_length
Length of the buffer used to store history of events.
uint32_t read_threads
the number of read threads to start
double read_thread_hertz
Number of valid messages allowed to be received per second.
std::pair< std::string, uint16_t > parse_address(std::string addr)
Copyright(c) 2020 Galois.