Session ID

A project log for HTTaP

Test Access Port over HTTP

yann-guidon-ygdesYann Guidon / YGDES 05/04/2020 at 23:530 Comments

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.