From 3f2acdab875f7ddd17099be3d957ab20a5f12154 Mon Sep 17 00:00:00 2001 From: offa Date: Tue, 7 Jan 2025 18:47:58 +0100 Subject: [PATCH] Replace deprecated asio::io_service and asio::ip::tcp::resolver::query Boost APIs --- src/TCP.cxx | 5 +---- src/TCP.h | 2 +- src/UDP.h | 2 +- src/UnixSocket.h | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/TCP.cxx b/src/TCP.cxx index 2ebb41a..4c39bb3 100644 --- a/src/TCP.cxx +++ b/src/TCP.cxx @@ -36,10 +36,7 @@ namespace influxdb::transports : mSocket(mIoService) { ba::ip::tcp::resolver resolver(mIoService); - ba::ip::tcp::resolver::query query(hostname, std::to_string(port)); - ba::ip::tcp::resolver::iterator resolverIterator = resolver.resolve(query); - ba::ip::tcp::resolver::iterator end; - mEndpoint = *resolverIterator; + mEndpoint = *(resolver.resolve(ba::ip::tcp::v4(), hostname, std::to_string(port), ba::ip::resolver_query_base::passive)); mSocket.open(mEndpoint.protocol()); reconnect(); } diff --git a/src/TCP.h b/src/TCP.h index e1e92e3..af22fbc 100644 --- a/src/TCP.h +++ b/src/TCP.h @@ -54,7 +54,7 @@ namespace influxdb::transports private: /// Boost Asio I/O functionality - boost::asio::io_service mIoService; + boost::asio::io_context mIoService; /// TCP socket boost::asio::ip::tcp::socket mSocket; diff --git a/src/UDP.h b/src/UDP.h index e8f3a95..22c8054 100644 --- a/src/UDP.h +++ b/src/UDP.h @@ -49,7 +49,7 @@ namespace influxdb::transports private: /// Boost Asio I/O functionality - boost::asio::io_service mIoService; + boost::asio::io_context mIoService; /// UDP socket boost::asio::ip::udp::socket mSocket; diff --git a/src/UnixSocket.h b/src/UnixSocket.h index db21540..8afd727 100644 --- a/src/UnixSocket.h +++ b/src/UnixSocket.h @@ -47,7 +47,7 @@ namespace influxdb::transports private: /// Boost Asio I/O functionality - boost::asio::io_service mIoService; + boost::asio::io_context mIoService; #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) /// Unix socket boost::asio::local::datagram_protocol::socket mSocket;