Skip to content

Commit

Permalink
Merge pull request #128 from MisterHW/keep-alive
Browse files Browse the repository at this point in the history
set keep-alive defaults for new connections
  • Loading branch information
j123b567 authored Nov 9, 2021
2 parents 77670c4 + 42841c3 commit 224f7ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/test-LwIP-netconn/scpi_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ static int processIoListen(scpi_t * context, user_data_t * user_data) {
} 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;
}
}
Expand All @@ -263,6 +267,10 @@ static int processSrqIoListen(scpi_t * context, user_data_t * user_data) {
} 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;
}
}
Expand Down
4 changes: 4 additions & 0 deletions examples/test-LwIP-netconn/scpi_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 224f7ce

Please sign in to comment.