How can the client know it lost the connection ? It has no access to the TCP/IP level...
The easy solution is to add a HTTP header to all HTTaP calls, called HTTaP_Session with a unique value. This would not need to appear on plain HTTP requests.
Compared to the minimal C code of the server, modern JavaScript has more freedom and power to analyse the response headers so this is a minimal effort for the server, which only has to come up with a new unique (sequential) value for each socket accept().
The client compares the most recently received session ID with the previous one, and can restart any configuration or initialisation if the communication link was interrupted.
The ID can be set from gettimeofday().tv_sec to prevent reuse.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.