17 #ifndef SCIP2_CONNECTION_H
18 #define SCIP2_CONNECTION_H
24 #include <boost/asio.hpp>
25 #include <boost/bind/bind.hpp>
26 #include <boost/function.hpp>
41 boost::asio::streambuf&,
const boost::posix_time::ptime&)>;
43 const boost::posix_time::ptime&)>;
60 boost::asio::streambuf& buf,
61 const boost::posix_time::ptime& time_read)
68 using Ptr = std::shared_ptr<Connection>;
70 virtual void spin() = 0;
71 virtual void stop() = 0;
73 virtual void startWatchdog(
const boost::posix_time::time_duration&) = 0;
95 boost::asio::io_service
io_;
97 boost::asio::streambuf
buf_;
123 const auto time_read = boost::posix_time::microsec_clock::universal_time();
136 const auto time_send = boost::posix_time::microsec_clock::universal_time();
149 boost::asio::async_read_until(
161 socket_.set_option(boost::asio::ip::tcp::no_delay(
true));
177 using Ptr = std::shared_ptr<ConnectionTcp>;
184 boost::asio::ip::tcp::endpoint endpoint(
185 boost::asio::ip::address::from_string(ip), port);
192 timeout_.expires_from_now(boost::posix_time::seconds(2));
210 boost::asio::async_write(
211 socket_, boost::asio::buffer(*buf),
225 #endif // SCIP2_CONNECTION_H