net: Disable nagle algo & Set keep_alive duration

This commit is contained in:
linuswck 2024-04-22 16:39:30 +08:00
parent f303ab639a
commit 554f292cab
1 changed files with 3 additions and 1 deletions

View File

@ -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::<Socket>(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);