Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : TIdIOHandler.ReadStream() hangs if I unplug the network cable

www.cryer.info
Managed Newsgroup Archive

TIdIOHandler.ReadStream() hangs if I unplug the network cable

Subject:TIdIOHandler.ReadStream() hangs if I unplug the network cable
Posted by:"Adrien Reboisson" (adrien-reboisson-at-astase-dot-c..@lala.com)
Date:Thu, 15 Nov 2007 11:40:21

Hi,

I'm using Indy 10.1.6 in a quite large project without any issue (until
this one !). I know that this release should be a little bit old, but I
want to avoid upgrading my entire application to a new Indy version if
the behavior I'll describe hasn't been reproduced nor fixed by the Indy
team in the new one.

Basically, I use WriteStream()/ReadStream() to transfer file stream
between two computers. What I discovered is, if I unplug the client
network connection cable (the client is the computer which send the
stream), Indy, on the server side does not detect the disconnection and
ReadStream() never returns :

    WriteLn('**** ENTERING IN READSTREAM *****');
    AIOHandler.ReadStream(ABlock, ABlockSize);
    WriteLn('**** LEAVING READSTREAM *****');

In this case, if the client dies in ReadStream(), "Leaving ReadStream"
is never displayed.

I can be wrong, but from my point of view, ReadStream() should raise an
exception in order to let the application's developer handling the event
(In my case, I want to be notified when such events occurs in order to
perform some other operations). It can also be an Indy or a system
timeout, but in this case I would be happy if it could be changed
(reduced) somewhere in the code.

So, is it an Indy issue ? Or is it by design ? How can I raise an
exception if the client dies when reading a stream ?

What puzzle me more is that when I kill the client application WITHOUT
unplugging the network cable, all goes well : the exception "Socket
Error # 10054 Connection reset by peer" is raised. What's the difference
between the two events ?

I'm using TIdTCPClient/TIdTCPServer with Delphi 2007.

Best regards,

A.R.

Replies:

www.cryer.info
Managed Newsgroup Archive