Jan Breuer
2021-11-09 224f7cee7c2c5592081e1dec640862f029323782
Merge pull request #128 from MisterHW/keep-alive

set keep-alive defaults for new connections
2个文件已修改
12 ■■■■■ 已修改文件
examples/test-LwIP-netconn/scpi_server.c 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/test-LwIP-netconn/scpi_server.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/test-LwIP-netconn/scpi_server.c
@@ -246,6 +246,10 @@
        } else {
            /* connection established */
            SCPI_Event_DeviceConnected(context, newconn);
            ip_set_option(newconn->pcb.tcp, SOF_KEEPALIVE);
            newconn->pcb.tcp->keep_idle   = SCPI_KEEP_IDLE;  // Override TCP_KEEPIDLE_DEFAULT  for this connection.
            newconn->pcb.tcp->keep_intvl  = SCPI_KEEP_INTVL; // Override TCP_KEEPINTVL_DEFAULT for this connection.
            newconn->pcb.tcp->keep_cnt    = SCPI_KEEP_CNT;   // Override TCP_KEEPCNT_DEFAULT   for this connection.
            user_data->io = newconn;
        }
    }
@@ -263,6 +267,10 @@
        } else {
            /* control connection established */
            SCPI_Event_ControlConnected(context, newconn);
            ip_set_option(newconn->pcb.tcp, SOF_KEEPALIVE);
            newconn->pcb.tcp->keep_idle   = SCPI_KEEP_IDLE;  // Override TCP_KEEPIDLE_DEFAULT  for this connection.
            newconn->pcb.tcp->keep_intvl  = SCPI_KEEP_INTVL; // Override TCP_KEEPINTVL_DEFAULT for this connection.
            newconn->pcb.tcp->keep_cnt    = SCPI_KEEP_CNT;   // Override TCP_KEEPCNT_DEFAULT   for this connection.
            user_data->control_io = newconn;
        }
    }
examples/test-LwIP-netconn/scpi_server.h
@@ -32,6 +32,10 @@
extern "C" {
#endif
#define SCPI_KEEP_IDLE    2000 // (ms) keepalive quiet time after last TCP packet
#define SCPI_KEEP_INTVL   1000 // (ms) keepalive repeat interval
#define SCPI_KEEP_CNT        4 // Retry count before terminating connection (SCPI_KEEP_INTVL * SCPI_KEEP_INTVL (ms)).
#define SCPI_DEVICE_PORT  5025 // scpi-raw standard port
#define SCPI_CONTROL_PORT 5026 // libscpi control port (not part of the standard)