Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Indy error when client is disconnected

Posted on 2004-08-23
6
Medium Priority
?
377 Views
Last Modified: 2010-04-05
When a client is forcibly disconnected, ie their internet connection drops, then millions of "Connection reset by Peer" errors are spawned. Why is this? All my code to perform functions on the socket checks whether the socket is connected before performing, so nothing should occur after this exception is occured surely? Please help, this is a time critical project. Thanks. PS also a "Connection reset by peer" error is also present in the Server app when this occurs, but it only displays one copy of this error message, then closes the debugger running the app as if nothing ever happened.
0
Comment
Question by:henrythacker
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 11874176
from the Delphi help:

"Write an OnError event handler to respond to errors that arise with the socket connection. Set the ErrorCode parameter to 0 if the OnError event handler successfully deals with the error condition, to prevent an ESocketError from being raised."

Occurs when the socket fails in making, using, or shutting down a connection.

Delphi syntax:

property OnError: TSocketErrorEvent;

C++ syntax:

__property TSocketErrorEvent OnError = {read=FOnError, write=FOnError};

Description

Write an OnError event handler to respond to errors that arise with the socket connection. Set the ErrorCode parameter to 0 if the OnError event handler successfully deals with the error condition, to prevent an ESocketError from being raised.

if you don't know exactly where the error is raising, use that to stop the exception from showing

the best way of doing it however would be to have a
try..except..end and handle any error in the Except..End part, like writing to a log file instead of showing the message to the user, also, if you are using events you need to handle the exceptions in the events as well
0
 
LVL 1

Author Comment

by:henrythacker
ID: 11874292
Sorry forgot to mention in the question that we are dealing with Indy sockets here in IdTCPClient and IdTCPServer components. Have tried blocking in the TRY and EXCEPT clauses around all things relating to the socket, so can't quite comprehend what is raising this error, unless it is an internal working of the socket, which is surely solveable, as Indy's own demo doesn't raise this error with the same conditions.
0
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 200 total points
ID: 11874579
do you have try..except in all your events as well? onConnected, OnStatus, etc

it happens that you have try..except in the code flow, but the code generates events, and those events generate exceptions outside your flow (and so, outside that try..except)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:henrythacker
ID: 11874688
Ok, i have found out that the error is when the component is polled for messages. I have enclosed this code in a try...except.. the only trouble is, the delphi error box pops up in place of my message, and since this error reoccurs for infinity, the application just ends up crashing out. Is there any way to prevent delphi handling the message during runtime too, and to make my code in the except clause take preference?
0
 
LVL 1

Author Comment

by:henrythacker
ID: 11874820
Sorry silly me, just running the whole thing outside of the IDE silenced the Delphi errors, and i saw my Except code being used instead. Thanks.
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 11874941
go to the Delphi Menu Tools, Debugger Options, Language Exceptions, turn off "Stop on Delphi exceptions", see if that helps you run your program from inside Delphi
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question