From 8aaacd282c1e09ca125afd622950e552e81b5eec Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Sat, 15 Aug 2026 10:54:29 -0500 Subject: [PATCH] refactor(rtps): use Socket::set_receive_buffer_size instead of raw setsockopt Fast-follow to the socket-option API (#714): the RTPS transport was the only place in the repo still calling setsockopt() on a raw native handle. Use the new espp::Socket::set_receive_buffer_size() for the DATA_FRAG receive-buffer enlarge, dropping the manual native_handle()/SOL_SOCKET/SO_RCVBUF plumbing and its platform-specific reinterpret_cast. Behaviour is unchanged (still best-effort). Co-Authored-By: Claude Opus 4.8 --- components/rtps/src/communication/EsppTransport.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/rtps/src/communication/EsppTransport.cpp b/components/rtps/src/communication/EsppTransport.cpp index 09e8fac2f..0690dbd38 100644 --- a/components/rtps/src/communication/EsppTransport.cpp +++ b/components/rtps/src/communication/EsppTransport.cpp @@ -175,11 +175,7 @@ EsppTransport::Channel *EsppTransport::createChannel(Ip4Port_t receivePort, bool // large (fragmented) sample is not dropped before the reactor drains it. // Best-effort: some stacks clamp SO_RCVBUF, so failure is ignored. Only // compiled when fragmentation is enabled (never on the ESP32 default build). - { - int rcvbuf = 4 * 1024 * 1024; // request 4 MB (kernel may clamp) - ::setsockopt(channel.socket->native_handle(), SOL_SOCKET, SO_RCVBUF, - reinterpret_cast(&rcvbuf), sizeof(rcvbuf)); - } + (void)channel.socket->set_receive_buffer_size(4 * 1024 * 1024); // request 4 MB (kernel may clamp) #endif if (!allow_reuse && !channel.socket->disable_reuse()) {