Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : Connection reset by Peer
| Subject: | Connection reset by Peer |
| Posted by: | "Michael Stieler" (michael.stiel..@rie.eu) |
| Date: | Thu, 24 Jan 2008 17:29:12 |
Hi,
I have the following problem with Indy 10.1.6:
- I connect a IdTcpClient to a target socket, successfully.
- the protocol implemented uses only WriteLn, followed by ReadLn
- I check for ReadLnTimeout or exceptions in this call
- If one of these occure, I call conn.Disconnect
Now I do something the program can't handle: I remove the network
cable from the computer.
=> The ReadLn call throws an exception: Socket Error # 10054
Connection reset by peer.
If I call the Connected Function it ALSO throws the same exception and
Connect doesn't work either.
So I tried the following work-around to close the connection:
try
if conn.Connected then conn.Disconnect;
except
{ Close the connection if Connected throws an exception }
try
conn.Disconnect;
except
end;
end;
But even this doesn't allow me to call conn.Connect at a later time,
because the exception is again thrown.
How can I leave this state? Is it the input/output buffers being not
empty because of a partial write/read?
Thanks
Michael