BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

10054 Connection was reset by peer

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Gerhard Venter
Guest





PostPosted: Sat Aug 19, 2006 3:51 am    Post subject: 10054 Connection was reset by peer Reply with quote



If the server drops the connection to a client for some reason I am able to
trap it but there is just no way I can try and reconnect (or reset) )the
client again without closing the application first. The moment you touch
either the Connect, Disconnect or Connected property it raises the 10054
exception.

How do I get around this problem?

Indy 10 Version 10.0.52
Back to top
Guillem
Guest





PostPosted: Mon Aug 21, 2006 7:08 pm    Post subject: Re: 10054 Connection was reset by peer Reply with quote



Gerhard Venter wrote:

Quote:
If the server drops the connection to a client for some reason I am
able to trap it but there is just no way I can try and reconnect (or
reset) )the client again without closing the application first.

i'm not an expert but this has something to do with the way Windows
handles the sockets. AFAIK there is no realistic way for you to know if
a connection has been lost or closed unless you use timeouts or try to
connect/disconnect.

If you haven't I would suggest to wrap your connect/disconnect in a
try..finally clause

Quote:
The
moment you touch either the Connect, Disconnect or Connected property
it raises the 10054 exception.

which is what happens when the remote host is stopped, rebooted,
disabled or it uses a hard close.

Quote:

Indy 10 Version 10.0.52

not that it will solve your problem but I would suggest to update to
the latest version. You can download it from

http://www.indyproject.org/Sockets/Download/DevSnapshot.en.html

--
Best regards :)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
Back to top
Gerhard Venter
Guest





PostPosted: Mon Aug 21, 2006 10:07 pm    Post subject: Re: 10054 Connection was reset by peer Reply with quote



"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:xn0eq8oqwfechw004 (AT) newsgroups (DOT) borland.com...
Quote:
i'm not an expert but this has something to do with the way Windows
handles the sockets. AFAIK there is no realistic way for you to know if
a connection has been lost or closed unless you use timeouts or try to
connect/disconnect.

Hi Guillem, thanks for the reply.

Well it must be the way Windows does it because I can reset the connection
to a Linux server without any problems. I have the following setup:

Linux Server <=> Windows Server <=> Windows Clients (Indy used in the
Windows server and client) the windows server app has a listener and the
client app has a listener just as the windows server.

When the connection goes down on the Linux Server I can recover gracefully
on the windows server and reconnect without restarting the app. But when the
windows server goes down I have to restart the app.

Quote:
If you haven't I would suggest to wrap your connect/disconnect in a
try..finally clause

True I have it in a try except but it only helps me detecting it but I cant
recover from it except to inform the user to close the app and start it
again, and they dont like that idea very much..

Aaaaahhhh Windows!!!
Back to top
Guillem
Guest





PostPosted: Tue Aug 22, 2006 3:01 pm    Post subject: Re: 10054 Connection was reset by peer Reply with quote

Gerhard Venter wrote:

Quote:
Hi Guillem, thanks for the reply.

Well it must be the way Windows does it because I can reset the
connection to a Linux server without any problems. I have the
following setup:

Linux Server <=> Windows Server <=> Windows Clients (Indy used in the
Windows server and client) the windows server app has a listener and
the client app has a listener just as the windows server.

When the connection goes down on the Linux Server I can recover
gracefully on the windows server and reconnect without restarting the
app. But when the windows server goes down I have to restart the app.

If you haven't I would suggest to wrap your connect/disconnect in a
try..finally clause

True I have it in a try except but it only helps me detecting it but
I cant recover from it except to inform the user to close the app and
start it again, and they dont like that idea very much..

don't use a try..except. Use a try..finally. For example,

idTCPclient.Connect;
try
//do your stuff
finally
idTCPClient.Disconnect;
end;

this way you enforce your TCP client to disconnect itself, whether
there is an exception or not. It should help you prevent your problem


Quote:

Aaaaahhhh Windows!!!

<g>

--
Best regards :)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
Back to top
Gerhard Venter
Guest





PostPosted: Wed Aug 23, 2006 3:28 am    Post subject: Re: 10054 Connection was reset by peer Reply with quote

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:xn0eq9wua6d86x000 (AT) newsgroups (DOT) borland.com...
Quote:
don't use a try..except. Use a try..finally. For example,

idTCPclient.Connect;
try
//do your stuff
finally
idTCPClient.Disconnect;
end;

this way you enforce your TCP client to disconnect itself, whether
there is an exception or not. It should help you prevent your problem


Actually I do but it still wont work but I found a funny work around that I
can't expain why it works, see below:

If I add the line marked, I don't have to restart my client app and can just
reconnect but if I take it out no luck. I cannot understand why as
Disconnect does do a call to that but it seems it never gets there.

try
Self.IOHandler.Write('blah blah...');
finally
Self.IOHandler.Close; <=== Work around - add this line
Self.Disconnect;
end;

Gerhard
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.