Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : Connection Broken Scenario

www.cryer.info
Managed Newsgroup Archive

Connection Broken Scenario

Subject:Connection Broken Scenario
Posted by:"PeaShooter_OMO" (jacquesv..@homemail.co.za)
Date:Wed, 18 Apr 2007 14:26:10

I am testing possible connection broken scenarios with two PCs (one with
TidTCPServer and another with TidTCPCLient) and ethernet between them
running through TWO switches.

I have a "Write" button on the CLient side that does the following and
nothing else:

try
    Client.IOHandler.WriteLn('HelloNow');
except
    """"""Do Something to indicate an Exception"""""""""""
end;


=============================
The Client firstly connects to the Server and everything is fine.

I then physically enplug the network cable at the Client's end (it might be
at the network card or the end at the switch closest to the Client). This is
obviously picked up by Windows as a "Network Cable unplugged" and when I
then try to "Write" the Client will get an exception. I am satisfied with
that. Will the Server know of this disconnect because as far as the Server
is concerned it still has a "Plugged Network Cable"?
=============================


I plug everything back in and RESTART all apps(Client and Server) from
scratch.

I do a Client.Connect again. Its fine.

I then physically enplug the network cable at the Server's end (it might be
at the network card or the end at the switch closest to the Server). This is
obviously picked up by Windows as a "Network Cable unplugged" at the
Server's side and the Server also has an exception raised of 10054 - Conn
Reset by Peer. So when I then try to "Write" from the Client, it does
nothing. No Exception is raised. I can even click that "Write" button many
times. Nothing happens. Or so it seems to me.

I then plug the cable back in. Still nothing happens at the Client. I wait a
while(few mins) and still nothing happens. I then click a few times on the
"Write" button again. Still nothing happens.

SO. The Server obviously knows in this case that the conncetion was not
there anymore thus the lines send by the Client is either lost or cached
somewhere. My first question is whether it is cached and where and how I
will clear that cache. It is not a problem here to have the Client detect
the disconnection because I can have the Client have a Status that tells it
that it is waiting for a response to a line it sent and it will timeout if
it doesn't get a response from the Server side after a time that I will set
into a timer.

=============================

I plug everything back in and RESTART all apps(Client and Server) from
scratch.

I do a Client.Connect again. Its fine.

Now I unplug the cable between the two switches. Now neither the Server or
the Client will know of a Windows "Net Cable Uplugged". So I "Write" from
the Client and nothing happens. NO Exception, nothing. As it seems to my
untrained eye. I also click the "write" button a few times to write.

I then plug the cable back in. Suddenly all the writes I did just now, comes
through to the Server. Which I think is right because all the sockets on
both sides were undisturbed. And there must be a cache somewhere for this to
happen. It might seem OK to some people but what if this was on a WAN or big
corporation and that physical connection somewhere were busted and took
maybe a day to fix. So I think the cache must be cleared. I can once again
can have a timer on the Client side waiting for a response, etc. But isn't
there also a timeout for the Writes. Where is the cache?

Thank you

Replies:

www.cryer.info
Managed Newsgroup Archive