LwIP raw api下使用tcp keep alive

时间:2023-03-09 00:20:18
LwIP raw api下使用tcp keep alive
// First, we should enable this macro in lwipopts.h
#define LWIP_TCP_KEEPALIVE // The following code is implemented after tcp_new() or in tcp_connected call back
... xxx_connected(..., struct tcp_pcb* tpcb, ...)
{
tpcb->so_options |= SOF_KEEPALIVE;
tpcb->keep_idle = ; // ms
tpcb->keep_intvl = ; // ms
tpcb->keep_cnt = ; // report error after 2 KA without response
}