From d710869f0a42285e81c72c1e5b9e76886e0d190a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 11 Mar 2022 19:44:13 +0100 Subject: [PATCH] Add Socket::set_send_buffer_size(). --- src/lib/dcpomatic_socket.cc | 18 ++++++++++++++++++ src/lib/dcpomatic_socket.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/lib/dcpomatic_socket.cc b/src/lib/dcpomatic_socket.cc index f4292e842..014e498e6 100644 --- a/src/lib/dcpomatic_socket.cc +++ b/src/lib/dcpomatic_socket.cc @@ -21,6 +21,7 @@ #include "compose.hpp" #include "dcpomatic_assert.h" +#include "dcpomatic_log.h" #include "dcpomatic_socket.h" #include "exceptions.h" #include @@ -76,6 +77,16 @@ Socket::connect (boost::asio::ip::tcp::endpoint endpoint) if (!_socket.is_open ()) { throw NetworkError (_("connect timed out")); } + + if (_send_buffer_size) { + boost::asio::socket_base::send_buffer_size old_size; + _socket.get_option(old_size); + + boost::asio::socket_base::send_buffer_size new_size(*_send_buffer_size); + _socket.set_option(new_size); + + LOG_GENERAL("Changed socket send buffer size from %1 to %2", old_size.value(), *_send_buffer_size); + } } @@ -243,3 +254,10 @@ Socket::finish_write_digest () write (buffer, size); } + +void +Socket::set_send_buffer_size (int size) +{ + _send_buffer_size = size; +} + diff --git a/src/lib/dcpomatic_socket.h b/src/lib/dcpomatic_socket.h index f4520e5cf..7dff979e0 100644 --- a/src/lib/dcpomatic_socket.h +++ b/src/lib/dcpomatic_socket.h @@ -42,6 +42,7 @@ public: return _socket; } + void set_send_buffer_size (int size); void connect (boost::asio::ip::tcp::endpoint); void write (uint32_t n); @@ -87,4 +88,5 @@ private: int _timeout; boost::scoped_ptr _read_digester; boost::scoped_ptr _write_digester; + boost::optional _send_buffer_size; }; -- 2.30.2