Skip to content

Commit

Permalink
fu
Browse files Browse the repository at this point in the history
  • Loading branch information
offa committed Jan 7, 2025
1 parent 39a50a1 commit 76456e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/TCP.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@

namespace influxdb::transports
{
namespace ba = boost::asio;

TCP::TCP(const std::string& hostname, int port)
: mSocket(mIoService)
{
ba::ip::tcp::resolver resolver(mIoService);
auto endpoints = resolver.resolve(ba::ip::tcp::v4(), hostname, std::to_string(port), ba::ip::resolver_query_base::passive);
boost::asio::ip::tcp::resolver resolver(mIoService);
auto endpoints = resolver.resolve(boost::asio::ip::tcp::v4(), hostname, std::to_string(port), boost::asio::ip::resolver_query_base::passive);
mEndpoint = endpoints->endpoint();
mSocket.open(mEndpoint.protocol());
reconnect();
Expand All @@ -50,15 +48,15 @@ namespace influxdb::transports
void TCP::reconnect()
{
mSocket.connect(mEndpoint);
mSocket.wait(ba::ip::tcp::socket::wait_write);
mSocket.wait(boost::asio::ip::tcp::socket::wait_write);
}

void TCP::send(std::string&& message)
{
try
{
message.append("\n");
const size_t written = mSocket.write_some(ba::buffer(message, message.size()));
const size_t written = mSocket.write_some(boost::asio::buffer(message, message.size()));
if (written != message.size())
{
throw InfluxDBException("Error while transmitting data");
Expand Down
5 changes: 2 additions & 3 deletions src/UDP.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ namespace influxdb::transports
: mSocket(mIoService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 0))
{
boost::asio::ip::udp::resolver resolver(mIoService);
boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), hostname, std::to_string(port));
boost::asio::ip::udp::resolver::iterator resolverInerator = resolver.resolve(query);
mEndpoint = *resolverInerator;
auto endpoints = resolver.resolve(boost::asio::ip::udp::v4(), hostname, std::to_string(port), boost::asio::ip::resolver_query_base::passive);
mEndpoint = endpoints->endpoint();
}

void UDP::send(std::string&& message)
Expand Down

0 comments on commit 76456e0

Please sign in to comment.