Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set keep-alive defaults for new connections #128

Merged
merged 3 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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