zl程序教程

您现在的位置是:首页 >  云平台

当前栏目

LwIP raw api下使用tcp keep alive

APITCP Raw keep alive LwIP 使用
2023-09-14 09:06:30 时间
// 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 }