jbanafato
asked on
TClientSocket Exceptions
Hey everyone. I'm working with a TClientSocket component. Here's my problem:
var Connection: TClientSocket
----
...
try
Connection.Open;
except
on EAsyncSocketError do ShowMessage('Error.');
end;
...
---
This construction will not catch exceptions thrown by the Connection object. Any ideas why? Is this a documented thing? Thanks for any help.
-Joe
var Connection: TClientSocket
----
...
try
Connection.Open;
except
on EAsyncSocketError do ShowMessage('Error.');
end;
...
---
This construction will not catch exceptions thrown by the Connection object. Any ideas why? Is this a documented thing? Thanks for any help.
-Joe
ASKER
Excellent, exactly what I'm looking for. That should fix my problem. Thank you very much.
-Joe
-Joe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To catch the exception use the ClientSocketError Event :
procedure TForm1.ClientSocket1Error(
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode := 0;
// If you dont set the ErrorCode to 0 so you got an exception
end;
Best Regards
Cesario