Solved

Indy error when client is disconnected

Posted on 2004-08-23
6
365 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
Comment Utility
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
Comment Utility
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 50 total points
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:henrythacker
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now