From f2190657f67a6c222c1b0f0efdc6aa4fc94bb8a5 Mon Sep 17 00:00:00 2001 From: Elena Mamontova Date: Tue, 1 Jul 2025 14:26:18 +0300 Subject: [PATCH 1/3] Parameter io_service repleced by io_context in the constructor Socket. --- include/radproto/socket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/radproto/socket.h b/include/radproto/socket.h index a4f3745..54cc431 100644 --- a/include/radproto/socket.h +++ b/include/radproto/socket.h @@ -12,7 +12,7 @@ namespace RadProto class Socket { public: - Socket(boost::asio::io_service& io_service, const std::string& secret, uint16_t port); + Socket(boost::asio::io_context& io_context, const std::string& secret, uint16_t port); void asyncReceive(const std::function&, const boost::asio::ip::udp::endpoint&)>& callback); void asyncSend(const Packet& response, const boost::asio::ip::udp::endpoint& destination, const std::function& callback); void close(boost::system::error_code& ec); From 323dcaca1fcebf1b8d2958480bb6a9a7c4eef2fd Mon Sep 17 00:00:00 2001 From: Elena Mamontova Date: Tue, 1 Jul 2025 15:10:15 +0300 Subject: [PATCH 2/3] Parameter io_service repleced by io_context in the Socket constructor definition.. --- src/socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index fa46d93..a6c49bf 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -24,8 +24,8 @@ std::string packetTypeToString(int type) } using Socket = RadProto::Socket; -Socket::Socket(boost::asio::io_service& io_service, const std::string& secret, uint16_t port) - : m_socket(io_service, udp::endpoint(udp::v4(), port)), +Socket::Socket(boost::asio::io_context& io_context, const std::string& secret, uint16_t port) + : m_socket(io_context, udp::endpoint(udp::v4(), port)), m_secret(secret) { } From 1e4bd0a80d42d11e0499ba86d03d55119b89001e Mon Sep 17 00:00:00 2001 From: Elena Mamontova Date: Tue, 1 Jul 2025 15:26:44 +0300 Subject: [PATCH 3/3] Source parameter name commented out in the checkReceive function. The io_service replaced by io_context in BOOST_AUTO_TEST_CASE(TestConstructor) and BOOST_AUTO_TEST_CASE(TestAsyncSend). --- tests/socket_tests.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/socket_tests.cpp b/tests/socket_tests.cpp index 55fea61..64b4dc8 100644 --- a/tests/socket_tests.cpp +++ b/tests/socket_tests.cpp @@ -35,7 +35,7 @@ namespace BOOST_REQUIRE(!ec); } - void checkReceive(const error_code& ec, const std::optional& p, boost::asio::ip::udp::endpoint source) + void checkReceive(const error_code& ec, const std::optional& p, boost::asio::ip::udp::endpoint /*source*/) { callbackReceiveCalled = true; BOOST_REQUIRE(!ec); @@ -112,9 +112,9 @@ BOOST_AUTO_TEST_SUITE(SocketTests) BOOST_AUTO_TEST_CASE(TestConstructor) { - boost::asio::io_service io_service; + boost::asio::io_context io_context; - BOOST_CHECK_NO_THROW(RadProto::Socket s(io_service, "secret", 3000)); + BOOST_CHECK_NO_THROW(RadProto::Socket s(io_context, "secret", 3000)); } @@ -129,17 +129,17 @@ BOOST_AUTO_TEST_CASE(TestAsyncSend) RadProto::Packet p(1, 208, auth, attributes, vendorSpecific); - boost::asio::io_service io_service; + boost::asio::io_context io_context; boost::asio::ip::udp::endpoint destination(boost::asio::ip::address_v4::from_string("127.0.0.1"), 3000); - RadProto::Socket s(io_service, "secret", 3000); + RadProto::Socket s(io_context, "secret", 3000); s.asyncSend(p, destination, checkSend); s.asyncReceive(checkReceive); - io_service.run(); + io_context.run(); BOOST_CHECK_MESSAGE(callbackSendCalled, "Function asyncSend hasn't called checkSend."); BOOST_CHECK_MESSAGE(callbackReceiveCalled, "Function asyncReceive hasn't called checkReceive.");