File tree Expand file tree Collapse file tree
include/ccapi_cpp/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222#ifndef RAPIDJSON_PARSE_ERROR_NORETURN
2323#define RAPIDJSON_PARSE_ERROR_NORETURN (parseErrorCode, offset ) throw std::runtime_error (#parseErrorCode)
2424#endif
25+
2526#ifndef CCAPI_WEBSOCKET_WRITE_BUFFER_SIZE
2627#define CCAPI_WEBSOCKET_WRITE_BUFFER_SIZE (1 << 20 )
2728#endif
29+
30+ #ifndef CCAPI_SOCKET_SEND_BUFFER_SIZE
31+ #define CCAPI_SOCKET_SEND_BUFFER_SIZE (1 << 20 )
32+ #endif
33+
34+ #ifndef CCAPI_SOCKET_RECEIVE_BUFFER_SIZE
35+ #define CCAPI_SOCKET_RECEIVE_BUFFER_SIZE (1 << 20 )
36+ #endif
37+
2838#include < regex>
2939
3040#include " boost/asio/strand.hpp"
@@ -1038,8 +1048,14 @@ class Service : public std::enable_shared_from_this<Service> {
10381048 [&](auto & streamPtr) {
10391049 using StreamType = std::decay_t <decltype (*streamPtr)>;
10401050
1041- // Set TCP_NODELAY
1042- beast::get_lowest_layer (*streamPtr).socket ().set_option (tcp::no_delay (true ));
1051+ auto & lowestLayer = beast::get_lowest_layer (*streamPtr).socket ();
1052+
1053+ // Disable Nagle
1054+ lowestLayer.set_option (tcp::no_delay (true ));
1055+
1056+ // Set buffer sizes (example: 1 MB)
1057+ lowestLayer.set_option (boost::asio::socket_base::send_buffer_size (CCAPI_SOCKET_SEND_BUFFER_SIZE ));
1058+ lowestLayer.set_option (boost::asio::socket_base::receive_buffer_size (CCAPI_SOCKET_RECEIVE_BUFFER_SIZE ));
10431059
10441060 if constexpr (std::is_same_v<StreamType, beast::websocket::stream<beast::ssl_stream<beast::tcp_stream>>>) {
10451061 CCAPI_LOGGER_TRACE (" before ssl async_handshake" );
You can’t perform that action at this time.
0 commit comments