Solved

Indy error when client is disconnected

Posted on 2004-08-23
6
369 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 50 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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