How to check for a closed http socket without losing any data? (MSDN
says to send something to server).
Somewhere in my code (after sending the http header in plain text) I'm
doing a loop with:
Loop:----------------
Socket.Receive //receive http data chunks
Socket.Send //'/r/n' data to check if connection is active
------------------------
The problem is that when connection is closed by the http server, the
send socket function will throw an exception and it is impossible to
receive the last bytes if the data arrives between Socket.Receive and
Socket.Send functions.
How to check for a closed http socket without losing any data? This
must be easy to explain. Someone must have done this... what is the
solution?
(My solution wasn't sending nothing at all, but instead searching for
the "</html>" tag in the bytes received... but that is a slow procedure
and may give deadlock if the main page has no "</html>" tag.)
Thanks for any response,
Nuno Magalhaes.