Skip to content

Commit

Permalink
Adjust receive buffer size to not lose fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianReimold committed Apr 11, 2024
1 parent 7685f66 commit f3c219c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/ecaludp_test/src/ecaludp_socket_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ TEST(EcalUdpSocket, AsyncBigMessage)
ASSERT_EQ(ec, asio::error_code());
}

// Set a big receive buffer size, so we will not lose fragments
{
asio::error_code ec;
socket.set_option(asio::socket_base::receive_buffer_size(1024 * 1024 * 5), ec);
ASSERT_FALSE(ec);
}


auto work = std::make_unique<asio::io_context::work>(io_context);
std::thread io_thread([&io_context]() { io_context.run(); });

Expand Down Expand Up @@ -202,7 +210,7 @@ TEST(EcalUdpSocket, CancelSyncReceive)
});

// Wait 10 milliseconds to make sure that the receiver is ready
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::this_thread::sleep_for(std::chrono::milliseconds(10));

// Cancel the receive
{
Expand All @@ -221,7 +229,6 @@ TEST(EcalUdpSocket, CancelSyncReceive)
rcv_thread.join();
}


// Send and Receive a small Hello World message using the sync API
TEST(EcalUdpSocket, SyncHelloWorldMessage)
{
Expand Down Expand Up @@ -329,6 +336,13 @@ TEST(EcalUdpSocket, SyncBigMessage)
rcv_socket.bind(asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), 14000), ec);
ASSERT_FALSE(ec);
}

// Set a big receive buffer size, so we will not lose fragments
{
asio::error_code ec;
rcv_socket.set_option(asio::socket_base::receive_buffer_size(1024 * 1024 * 5), ec);
ASSERT_FALSE(ec);
}

asio::ip::udp::endpoint sender_endpoint;

Expand Down

0 comments on commit f3c219c

Please sign in to comment.