"JSheble" <
XXXX@XXXXX.COM>writes
Quote
So if I am reading this correctly, there's nothing I can do to detect
if the client has dropped their connection at all?
No, that is not what I said. I said if a "premature" disconnect happens,
such as the network going down unexpectedly, then the disconnect is not
detected right away. That is a "feature" of TCP itself, not Indy
specifically. The socket stack is designed to persist active connections
for a period of time during outages, in case the network comes back up in a
timely fashion and the stack can reestablish the same connection internally.
Small network outages are common, especially over the Internet. Most of the
time, you won't even notice the outages, and neither will Indy.
As long as both sides of the connection actively close down the socket
connection gracefully, meaning they both call Disconnect() and such, then
yes, Indy (and the socket stack) will detect the disconnect immediately. It
is the "premature" disconnects that are not detected right away, because the
socket stack itself is keeping the socket "alive" for an extra period of
time. Eventually, if the connection cannot be reestablished, then the
socket stack will timeout and invalidate the socket, at which point Indy
will start detecting errors. But that may not happen for about a minute at
least (or possibly longer).
Quote
Would the TIdTelnetServer component allow me to detect
if the client dropped the connection?
The issue I have described has nothing to do with TIdTelnetServer
specifically. This effects all TCP-based servers in general.
Quote
From time to time, they're dropping their connection ungracefully,
but I am still sending out a response.
There is nothing you can do about that, because the socket stack itself
doesn't know that the socket is truely gone for awhile.
Quote
If I could tell the connection is no longer there, then I can log the
response instead, and we can then audit or track from there.
The best way would be to make sure that the client always closes the socket
gracefully, then there is no problem. But if you do have to deal with
premature disconnects as well, then the most reliable way to shorten the
timeout is to simply require the client to send the server "keepalive"
packets every so often, to let the server know that the client is still
active. If the server does not receive a packet in a timely fashion, then
just assume the client is gone and shut down the socket.
Gambit