| View previous topic :: View next topic |
| Author |
Message |
AKZ Guest
|
Posted: Thu Feb 19, 2004 1:03 pm Post subject: how to get rid of error msg? |
|
|
Hi,
i try to connect to a tcpserver application, but when server is not
reachable i got "Socket Error #10057. Socket is not connected" msg although
i wrapped everything into try..except and try..finally blocks...
here is my code:
=================================================================
try
TCPClient.Host := DefaultServerIP;
TCPClient.Port := DefaultServerPort;
TCPClient.Connect;
try
try
// Communications here
finally TCPClient.Disconnect; end;
except
on E: EIdException do
begin
ShowMessage('An network error occurred during communication: ' +
E.Message);
end;
on E: Exception do
begin
ShowMessage('An unknown error occurred during communication: '+
E.Message);
end;
end;
except
on E: EIdException do
begin
ShowMessage('An network error occurred while trying to connect: '+
E.Message);
end;
on E: Exception do
begin
ShowMessage('An unknown error occurred while trying to connect: '+
E.Message);
end;
end;
=================================================================
why TCPClient.Connect; causes msg popup and how to get rid of that?
Thanks in advance
|
|
| Back to top |
|
 |
Cruxy Guest
|
Posted: Thu Feb 19, 2004 3:15 pm Post subject: Re: how to get rid of error msg? |
|
|
Enter an OnError Handler into the component. The winsock itself does
not raise any exception...
|
|
| Back to top |
|
 |
AKZ Guest
|
Posted: Thu Feb 19, 2004 4:39 pm Post subject: Re: how to get rid of error msg? |
|
|
How can i do that? there is no any OnError event on TIdTCPClient component.
Thanks in advance
"Cruxy" <cruxyATcruxyDOTnet> wrote
| Quote: | Enter an OnError Handler into the component. The winsock itself does
not raise any exception...
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Feb 19, 2004 7:21 pm Post subject: Re: how to get rid of error msg? |
|
|
"Cruxy" <cruxyATcruxyDOTnet> wrote
| Quote: | Enter an OnError Handler into the component.
|
AKZ is using Indy, not TClientSocket. There is no OnError event.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Feb 19, 2004 7:23 pm Post subject: Re: how to get rid of error msg? |
|
|
"AKZ" <kirez (AT) freemail (DOT) org.mk> wrote
| Quote: | why TCPClient.Connect; causes msg popup and how to get rid of that?
|
Are you running inside the IDE debugger at the time? If so, then what you
describe is normal behavior. Indy uses exceptions internally, and the
debugger catches all exceptions before the application does. Simply press F9
to pass the exception back to the application for normal handling. If you
want to stop the debugger from displaying certain exceptions, then you need
to go into the debugger's Preferences and add the exception types to the
Debugger's ignore list.
Gambit
|
|
| Back to top |
|
 |
AKZ Guest
|
Posted: Thu Feb 19, 2004 7:53 pm Post subject: Re: how to get rid of error msg? |
|
|
no matter i run it from delphi ide (normal or tracing) or as single exe
(delphi closed) i got this error msg.
--
Thanks in advance
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote
| Quote: |
"AKZ" <kirez (AT) freemail (DOT) org.mk> wrote in message
news:4034b4f1 (AT) newsgroups (DOT) borland.com...
why TCPClient.Connect; causes msg popup and how to get rid of that?
Are you running inside the IDE debugger at the time? If so, then what you
describe is normal behavior. Indy uses exceptions internally, and the
debugger catches all exceptions before the application does. Simply press
F9
to pass the exception back to the application for normal handling. If you
want to stop the debugger from displaying certain exceptions, then you
need
to go into the debugger's Preferences and add the exception types to the
Debugger's ignore list.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Feb 19, 2004 8:54 pm Post subject: Re: how to get rid of error msg? |
|
|
"AKZ" <kirez (AT) freemail (DOT) org.mk> wrote
| Quote: | no matter i run it from delphi ide (normal or tracing) or
as single exe (delphi closed) i got this error msg.
|
Based on the code you have shown so far, that is not possible. Your own
message boxes, not any native ones, would be displayed if an error occured.
Gambit
|
|
| Back to top |
|
 |
Cruxy Guest
|
Posted: Fri Feb 20, 2004 7:43 am Post subject: Re: how to get rid of error msg? |
|
|
| Quote: | AKZ is using Indy, not TClientSocket. There is no OnError event.
|
Sorry....
|
|
| Back to top |
|
 |
Cruxy Guest
|
Posted: Fri Feb 20, 2004 7:53 am Post subject: Re: how to get rid of error msg? |
|
|
| Quote: | Based on the code you have shown so far, that is not possible. Your
own message boxes, not any native ones, would be displayed if an
error occured.
|
That could happen. I think the problem is that Indy starts a thread for
checking errors on the connect.
So if only using the TCP socket, maybe the TClientSocket is a faster
solution??
|
|
| Back to top |
|
 |
Chad Z. Hower aka Kudzu Guest
|
Posted: Fri Feb 20, 2004 10:38 am Post subject: Re: how to get rid of error msg? |
|
|
"Cruxy" <cruxyATcruxyDOTnet> wrote in news:4035bd86$1 (AT) newsgroups (DOT) borland.com:
| Quote: | That could happen. I think the problem is that Indy starts a thread for
checking errors on the connect.
|
Only if you specify a timeout.
| Quote: | So if only using the TCP socket, maybe the TClientSocket is a faster
solution??
|
Nope.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Got Indy? Got the book?
http://www.atozed.com/indy/book/
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Feb 20, 2004 9:09 pm Post subject: Re: how to get rid of error msg? |
|
|
"Cruxy" <cruxyATcruxyDOTnet> wrote
| Quote: | That could happen. I think the problem is that Indy starts
a thread for checking errors on the connect.
|
That thread does its own exception handling internally to prevent any errors
from appearng, and then it stores any thrown exception for the actual socket
thread to process later once the connect thread terminates.
Gambit
|
|
| Back to top |
|
 |
Cruxy Guest
|
Posted: Mon Feb 23, 2004 7:40 am Post subject: Re: how to get rid of error msg? |
|
|
| Quote: | That thread does its own exception handling internally to prevent any
errors from appearng, and then it stores any thrown exception for the
actual socket thread to process later once the connect thread
terminates.
|
Normally it should. I had a similar problem using Indy some times ago -
and wrote my own component....
(After searching long enough through Indy....)
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Feb 23, 2004 7:45 pm Post subject: Re: how to get rid of error msg? |
|
|
"Cruxy" <cruxyATcruxyDOTnet> wrote
| Quote: | Normally it should.
|
Not normally - always. The connect thread is completely exception safe, any
exceptions it throws cannot reach the default exception handler which
displays a popup message. The information from the exception is stored into
class member variables, and then TIdTCPClient (actually, TIdIOHandlerSocket)
checks those values and raises its own exception to the caller when needed.
There is nothing in AKZ's original code that would be causing the behavior
he is describing.
Gambit
|
|
| Back to top |
|
 |
Cruxy Guest
|
Posted: Tue Feb 24, 2004 7:26 am Post subject: Re: how to get rid of error msg? |
|
|
| Quote: | Normally it should.
Not normally - always. The connect thread is completely exception
safe, any exceptions it throws cannot reach the default exception
handler which displays a popup message. The information from the
exception is stored into class member variables, and then
TIdTCPClient (actually, TIdIOHandlerSocket) checks those values and
raises its own exception to the caller when needed. There is nothing
in AKZ's original code that would be causing the behavior he is
describing.
|
Everything is possible, although sometimes without explanation.
'Always' in software I'd not use.
As described before, either AKZ uses Indy on an other place too or
there must be a point where the Exception comes through (or the
bahviour is not reproducible (or he tells us s*** - what I don't
believe)). My only point is to try to find a possibility of a leak in
that - at first sight impossible failure case.
Completely other question: What's if the remote computer kills the
connection?
For AKZ maybe MadExcept helps? www.madshi.com I think.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Feb 24, 2004 8:32 pm Post subject: Re: how to get rid of error msg? |
|
|
"Cruxy" <cruxyATcruxyDOTnet> wrote
| Quote: | Completely other question: What's if the remote
computer kills the connection?
|
Indy will detect the disconnect the next time it accesses the socket, and an
exception will be thrown, if needed, to the caller that invoked the access.
Gambit
|
|
| Back to top |
|
 |
|