Skip to content

Commit

Permalink
Also set send buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianReimold committed Apr 11, 2024
1 parent f3c219c commit 0e20472
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ecaludp/src/socket_npcap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

#include <recycle/shared_pool.hpp>

// TODO: Add sync operations

namespace ecaludp
{

Expand Down
21 changes: 18 additions & 3 deletions tests/ecaludp_test/src/ecaludp_socket_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <string>
#include <thread>

// TODO: Add a test for cancelling an async operation

// Send and Receive a small Hello World message using the async API
TEST(EcalUdpSocket, AsyncHelloWorldMessage)
{
Expand Down Expand Up @@ -120,13 +122,19 @@ TEST(EcalUdpSocket, AsyncBigMessage)
ASSERT_EQ(ec, asio::error_code());
}

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

// Set a big receive buffer size, so we will not lose incoming 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 @@ -337,7 +345,7 @@ TEST(EcalUdpSocket, SyncBigMessage)
ASSERT_FALSE(ec);
}

// Set a big receive buffer size, so we will not lose fragments
// Set a big receive buffer size, so we will not lose incoming fragments
{
asio::error_code ec;
rcv_socket.set_option(asio::socket_base::receive_buffer_size(1024 * 1024 * 5), ec);
Expand Down Expand Up @@ -366,6 +374,13 @@ TEST(EcalUdpSocket, SyncBigMessage)
const asio::ip::udp::endpoint destination(asio::ip::address_v4::loopback(), 14000);
send_socket.open(destination.protocol());

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

// Send a message
{
asio::error_code ec;
Expand Down

0 comments on commit 0e20472

Please sign in to comment.