diff options
Diffstat (limited to 'embassy-net/src/tcp.rs')
| -rw-r--r-- | embassy-net/src/tcp.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index d0230b581..b4db7b88c 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | //! Incoming connections when no socket is listening are rejected. To accept many incoming | 8 | //! Incoming connections when no socket is listening are rejected. To accept many incoming |
| 9 | //! connections, create many sockets and put them all into listening mode. | 9 | //! connections, create many sockets and put them all into listening mode. |
| 10 | 10 | ||
| 11 | use core::future::{poll_fn, Future}; | 11 | use core::future::{Future, poll_fn}; |
| 12 | use core::mem; | 12 | use core::mem; |
| 13 | use core::task::{Context, Poll}; | 13 | use core::task::{Context, Poll}; |
| 14 | 14 | ||
| @@ -18,8 +18,8 @@ use smoltcp::socket::tcp; | |||
| 18 | pub use smoltcp::socket::tcp::State; | 18 | pub use smoltcp::socket::tcp::State; |
| 19 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; | 19 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; |
| 20 | 20 | ||
| 21 | use crate::time::duration_to_smoltcp; | ||
| 22 | use crate::Stack; | 21 | use crate::Stack; |
| 22 | use crate::time::duration_to_smoltcp; | ||
| 23 | 23 | ||
| 24 | /// Error returned by TcpSocket read/write functions. | 24 | /// Error returned by TcpSocket read/write functions. |
| 25 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] | 25 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
| @@ -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. |
