Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Indy error when client is disconnected

Posted on 2004-08-23
6
Medium Priority
?
374 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

715 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