summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-03-11 19:44:13 +0100
committerCarl Hetherington <cth@carlh.net>2022-08-15 18:22:58 +0200
commitd710869f0a42285e81c72c1e5b9e76886e0d190a (patch)
tree2d20b9727c27bb9748d8c2d74625999a30295e52 /src/lib
parentbb78e4dcbdf5f9592679f0262b97de240fbd62e7 (diff)
Add Socket::set_send_buffer_size().
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcpomatic_socket.cc18
-rw-r--r--src/lib/dcpomatic_socket.h2
2 files changed, 20 insertions, 0 deletions
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 <boost/bind/bind.hpp>
@@ -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<Digester> _read_digester;
boost::scoped_ptr<Digester> _write_digester;
+ boost::optional<int> _send_buffer_size;
};