On 28/10/2022 17:29, Sean Conner wrote:
It was thus said that the Great Mateusz Viste once stated:In the discussed context, maybe a saner convention would be simply: "if the file or menu does not exist, then a well-behaved server SHOULD close the connection right away, without sending back anything at all - ideally shutting the connection using a TCP RST if possible" ?That's a decent idea. I don't know how to ensure a TCP RST though, nor how to check for it.
This depends on the environment and stack being used. In WatTCP / Watt32 there are specialized routines for that: sock_close() for clean shutdown and sock_abort() for RST.
In the more common (nowadays) BSD socket-style POSIX API, closing with an RST occurs AFAIK in two conditions:
- when closing a socket with pending (unread) data - when closing a socket with SO_LINGER set to 0Checking for a RST is quite simple under BSD/POSIX - recv() returns 0 on a clean (FIN/ACK FIN/ACK) connection close, and -1 on error (incl. RST, in which case errno==ECONNRESET).
Mateusz