Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ if (BUILDING_FOR_ANDROID) # Boost is found in variables set by android toolchain

include_directories(${ANDROID_BOOST_INCLUDE_DIR})
else() # Find boost normally
find_package(Boost REQUIRED COMPONENTS system)
# Boost.System is header-only since Boost 1.69 and its CMake package was
# removed in Boost 1.89, so only request the component on older versions.
find_package(Boost REQUIRED OPTIONAL_COMPONENTS system)
if (TARGET Boost::system)
set(BOOST_SYSTEM_TARGET Boost::system)
else()
set(BOOST_SYSTEM_TARGET Boost::headers)
endif()
endif()

# Library target
Expand All @@ -68,7 +75,7 @@ target_include_directories(${ISOOBJECT_LIBRARY} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/iso22133
)
set(ISO_OBJ_LIBS
${ISO22133_LIBRARY} atomic pthread Boost::system)
${ISO22133_LIBRARY} atomic pthread ${BOOST_SYSTEM_TARGET})
set(ISO_OBJ_LIBS_ANDROID
${ISO22133_LIBRARY} atomic ${boost_system})
if (BUILDING_FOR_ANDROID)
Expand Down
4 changes: 2 additions & 2 deletions inc/tcpServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class TcpServer {
public:
TcpServer(std::string ip, std::uint32_t port) :
acceptor(context, boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::from_string(ip), port)),
acceptor(context, boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address_v4(ip), port)),
socket(context),
acceptIncoming(true) {
setBufferSize(defaultBufferSize);
Expand All @@ -39,7 +39,7 @@ class TcpServer {
socket.shutdown(boost::asio::socket_base::shutdown_both);
socket.close();
}
context.reset();
context.restart();
} catch (boost::system::system_error& e) {
std::cerr << "Error when closing socket: " << e.what() << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion inc/udpServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class UdpServer {
public:
UdpServer(const std::string& ip, std::uint32_t port) :
socket(context, boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4::from_string(ip), port)) {
socket(context, boost::asio::ip::udp::endpoint(boost::asio::ip::make_address_v4(ip), port)) {
setBufferSize(defaultBufferSize);
}
UdpServer() :
Expand Down
2 changes: 1 addition & 1 deletion iso22133
Submodule iso22133 updated 1 files
+4 −2 CMakeLists.txt
2 changes: 1 addition & 1 deletion src/iso22133object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ int TestObject::handleTCPMessage(char* buffer, int bufferLen) {
int TestObject::handleUDPMessage(char* buffer, int bufferLen, int udpSocket, char* addr, const std::uint32_t port) {
if (awaitingFirstHeab) {
boost::asio::ip::udp::endpoint udpEp =
boost::asio::ip::udp::endpoint(boost::asio::ip::address::from_string(addr), port);
boost::asio::ip::udp::endpoint(boost::asio::ip::make_address(addr), port);
processChannel.setEndpoint(udpSocket, udpEp);
;
this->startSendMonr();
Expand Down
8 changes: 4 additions & 4 deletions tests/isoObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ControlCenterEmulator {
void connect() {
try {
tcpSocket.connect(
ip::tcp::endpoint(ip::address_v4::from_string(listenIP), ISO_22133_DEFAULT_OBJECT_TCP_PORT));
ip::tcp::endpoint(ip::make_address_v4(listenIP), ISO_22133_DEFAULT_OBJECT_TCP_PORT));
} catch (boost::system::system_error err) {
EXPECT_EQ(1, 2) << "TCP Connection failed";
}
Expand All @@ -51,7 +51,7 @@ class ControlCenterEmulator {
tcpSocket.send(buffer(data));
}
void sendUDP(const std::vector<char>& data) {
ip::udp::endpoint receiverEP(ip::address_v4::from_string(listenIP), ISO_22133_OBJECT_UDP_PORT);
ip::udp::endpoint receiverEP(ip::make_address_v4(listenIP), ISO_22133_OBJECT_UDP_PORT);
udpSocket.send_to(buffer(data), receiverEP);
}
void disconnect() {
Expand Down Expand Up @@ -161,8 +161,8 @@ class ControlCenterEmulator {
class ControllerEmulator {
public:
ControllerEmulator(const std::string& listenIP = "127.0.0.1") :
acceptor(context, ip::tcp::endpoint(ip::address_v4::from_string(listenIP), ISO_22133_DEFAULT_OBJECT_TCP_PORT)),
udpSocket(context, ip::udp::endpoint(ip::address_v4::from_string(listenIP), ISO_22133_OBJECT_UDP_PORT)) {}
acceptor(context, ip::tcp::endpoint(ip::make_address_v4(listenIP), ISO_22133_DEFAULT_OBJECT_TCP_PORT)),
udpSocket(context, ip::udp::endpoint(ip::make_address_v4(listenIP), ISO_22133_OBJECT_UDP_PORT)) {}
virtual ~ControllerEmulator() = default;
/*
* Remember to delete the socket after!!
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class tcpServer_connect_new_socket : public ::testing::Test {
TEST_F(tcpServer_connect_new_socket, connect) {
// Connect to server

io_service io_service;
io_context io_service;
ip::tcp::socket socket(io_service);
ip::tcp::endpoint endpoint(ip::address::from_string("127.0.0.1"), 1234);
ip::tcp::endpoint endpoint(ip::make_address("127.0.0.1"), 1234);
try {
socket.connect(endpoint);
} catch (boost::system::system_error& e) {
Expand All @@ -59,7 +59,7 @@ class tcpServer_on_existing_socket : public ::testing::Test {
server = NULL;
std::shared_future<void> readyFuture(readyPromise.get_future());
// Start server
ip::tcp::endpoint ep(ip::address_v4::from_string("127.0.0.1"), 1234);
ip::tcp::endpoint ep(ip::make_address_v4("127.0.0.1"), 1234);
listener.open(ep.protocol());
listener.set_option(ip::tcp::acceptor::reuse_address(true));
listener.bind(ep);
Expand Down
Loading