From 554f292cab886497108cc16e787d7cd5bb6ee5ee Mon Sep 17 00:00:00 2001 From: linuswck Date: Mon, 22 Apr 2024 16:39:30 +0800 Subject: [PATCH] net: Disable nagle algo & Set keep_alive duration --- src/net/net.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/net/net.rs b/src/net/net.rs index f14c316..4d60287 100644 --- a/src/net/net.rs +++ b/src/net/net.rs @@ -6,7 +6,7 @@ use log::{debug, info}; use smoltcp::{ iface::{ self, Interface, SocketHandle, SocketSet, SocketStorage - }, socket::tcp::{Socket, SocketBuffer, State}, time::Instant, wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address, Ipv4Cidr} + }, socket::tcp::{Socket, SocketBuffer, State}, time::{Instant, Duration}, wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address, Ipv4Cidr} }; use stm32_eth::{ Parts, EthPins, PartsIn, @@ -160,6 +160,8 @@ impl ServerHandle { for i in 0..NUM_OF_SOCKETS { let socket = socket_set.get_mut::(tcp_handles[i]); socket.listen(socket_addr).ok(); + socket.set_keep_alive(Some(Duration::from_secs(1))); + socket.set_nagle_enabled(false); } iface.poll(Instant::from_millis(i64::from(sys_timer::now())), &mut &mut dma, &mut socket_set);