保捱科技网
您的当前位置:首页LwIP raw api下使用tcp keep alive

LwIP raw api下使用tcp keep alive

来源:保捱科技网
// First, we should enable this macro in lwipopts.h
#define LWIP_TCP_KEEPALIVE 1

//
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 = 5000; // ms tpcb->keep_intvl = 5000; // ms tpcb->keep_cnt = 2; // report error after 2 KA without response }

 

因篇幅问题不能全部显示,请点此查看更多更全内容