Skip to content

Commit d63f5ce

Browse files
committed
Merge branch 'cboulay/sock_buff_config' into cboulay/test
2 parents cd96eca + 3709892 commit d63f5ce

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/api_config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ void api_config::load_from_file(const std::string &filename) {
207207
time_probe_max_rtt_ = pt.get("tuning.TimeProbeMaxRTT", 0.128);
208208
outlet_buffer_reserve_ms_ = pt.get("tuning.OutletBufferReserveMs", 5000);
209209
outlet_buffer_reserve_samples_ = pt.get("tuning.OutletBufferReserveSamples", 128);
210+
socket_send_buffer_size_ = pt.get("tuning.SendSocketBufferSize", 0);
210211
inlet_buffer_reserve_ms_ = pt.get("tuning.InletBufferReserveMs", 5000);
211212
inlet_buffer_reserve_samples_ = pt.get("tuning.InletBufferReserveSamples", 128);
213+
socket_receive_buffer_size_ = pt.get("tuning.ReceiveSocketBufferSize", 0);
212214
smoothing_halftime_ = pt.get("tuning.SmoothingHalftime", 90.0F);
213215
force_default_timestamps_ = pt.get("tuning.ForceDefaultTimestamps", false);
214216

src/api_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,14 @@ class api_config {
174174
int outlet_buffer_reserve_ms() const { return outlet_buffer_reserve_ms_; }
175175
/// Default pre-allocated buffer size for the outlet, in samples (irregular streams).
176176
int outlet_buffer_reserve_samples() const { return outlet_buffer_reserve_samples_; }
177+
/// Default socket send buffer size, in bytes.
178+
int socket_send_buffer_size() const { return socket_send_buffer_size_; }
177179
/// Default pre-allocated buffer size for the inlet, in ms (regular streams).
178180
int inlet_buffer_reserve_ms() const { return inlet_buffer_reserve_ms_; }
179181
/// Default pre-allocated buffer size for the inlet, in samples (irregular streams).
180182
int inlet_buffer_reserve_samples() const { return inlet_buffer_reserve_samples_; }
183+
/// Default socket receive buffer size, in bytes.
184+
int socket_receive_buffer_size() const { return socket_receive_buffer_size_; }
181185
/// Default halftime of the time-stamp smoothing window (if enabled), in seconds.
182186
float smoothing_halftime() const { return smoothing_halftime_; }
183187
/// Override timestamps with lsl clock if True
@@ -235,8 +239,10 @@ class api_config {
235239
double time_probe_max_rtt_;
236240
int outlet_buffer_reserve_ms_;
237241
int outlet_buffer_reserve_samples_;
242+
int socket_send_buffer_size_;
238243
int inlet_buffer_reserve_ms_;
239244
int inlet_buffer_reserve_samples_;
245+
int socket_receive_buffer_size_;
240246
float smoothing_halftime_;
241247
bool force_default_timestamps_;
242248
};

src/tcp_server.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ client_session::~client_session() {
267267
void client_session::begin_processing() {
268268
try {
269269
sock_->set_option(asio::ip::tcp::no_delay(true));
270+
if (api_config::get_instance()->socket_send_buffer_size() > 0)
271+
sock_->set_option(asio::socket_base::send_buffer_size(api_config::get_instance()->socket_send_buffer_size()));
272+
if (api_config::get_instance()->socket_receive_buffer_size() > 0)
273+
sock_->set_option(asio::socket_base::receive_buffer_size (api_config::get_instance()->socket_receive_buffer_size()));
270274
// register this socket as "in-flight" with the server (so that any subsequent ops on it can
271275
// be aborted if necessary)
272276
serv_->register_inflight_socket(sock_);

0 commit comments

Comments
 (0)