diff options
| author | Matthias Behr <[email protected]> | 2025-11-08 07:14:32 +0100 |
|---|---|---|
| committer | Matthias Behr <[email protected]> | 2025-11-08 07:52:33 +0100 |
| commit | 2c344b9a6efc7687e45897078f059d1c4c15a58f (patch) | |
| tree | c9a69527d6a736795522b0b7b8abaf333d1e712b /embassy-net/src | |
| parent | b68253e1aa38a9251b10219df4da3519cecf33e7 (diff) | |
feat: add set_nagle_enabled to TcpSocket
Adding fn TcpSocket::set_nagle_enable to control
the nagle algorithm for this socket.
Diffstat (limited to 'embassy-net/src')
| -rw-r--r-- | embassy-net/src/tcp.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 6792c5526..b4db7b88c 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -373,6 +373,20 @@ impl<'a> TcpSocket<'a> { | |||
| 373 | self.io.with_mut(|s, _| s.set_hop_limit(hop_limit)) | 373 | self.io.with_mut(|s, _| s.set_hop_limit(hop_limit)) |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | /// Enable or disable Nagles's algorithm. | ||
| 377 | /// | ||
| 378 | /// By default, Nagle's algorithm is enabled. | ||
| 379 | /// When enabled, Nagle’s Algorithm prevents sending segments smaller | ||
| 380 | /// than MSS if there is data in flight (sent but not acknowledged). | ||
| 381 | /// In other words, it ensures at most only one segment smaller than | ||
| 382 | /// MSS is in flight at a time. | ||
| 383 | /// It ensures better network utilization by preventing sending many | ||
| 384 | /// very small packets, at the cost of increased latency in some | ||
| 385 | /// situations, particularly when the remote peer has ACK delay enabled. | ||
| 386 | pub fn set_nagle_enabled(&mut self, enabled: bool) { | ||
| 387 | self.io.with_mut(|s, _| s.set_nagle_enabled(enabled)) | ||
| 388 | } | ||
| 389 | |||
| 376 | /// Get the local endpoint of the socket. | 390 | /// Get the local endpoint of the socket. |
| 377 | /// | 391 | /// |
| 378 | /// Returns `None` if the socket is not bound (listening) or not connected. | 392 | /// Returns `None` if the socket is not bound (listening) or not connected. |
