set keep-alive defaults for new connections #128
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Configure scpi-specific keep-alive settings for new connections. Without these, a connection lost on the client side blocks the server baiscally indefinitely, requiring a reset or some means to recover via another port or interface.
scpi server connection timeout is chosen such that when idle, zero window probes are sent periodically, and the connection is closed when they fail SCPI_KEEP_CNT times.
To change the defaults for all connections, add these values (lwipopts.h):
For keep-alive settings to be used, keep-alive needs to be enabled, and LwIP timers need to be used.
in lwipopts.h:
To allow LwIP timer operation, set (in opt.h or lwipopts.h):
(also requires FreeRTOS USE_TIMERS 1 or, for non-OS implementations, calling sys_check_timeouts() in the main loop).
tcp_priv.h
tcp_tmr();
is called every 250 ms to keep track of timeouts, which is handled internally.Also note: when other connections are used (e.g. http server listening socket), revisit memory pool sizes (lwipopts.h):
(default is 4, which can be exhausted by scpi server when two connections are active on top of the two listening socket protocol control block (pcb) structs which stay allocated.