Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ESocketError

Status
Not open for further replies.

lobOnline

Programmer
Apr 5, 2001
12
NL
I'm using a TClientSocket component. When I do a connect to an internet address (not ip), but I'm not connected to the internet I get an ESocketEror resulting in the following message: "Windows socket error: (11001), on API 'Async Lookup'.I'm trying to catch this ESocketError. But I can't!

I know there is an OnError event and I have a handler for it. I know this Error handler is working because occassionaly it's called.

I've tried many things like

try
{
Socket->Open();
}
catch(ESocketError &e)
{
Error("Could not open socket!");
}

but they did not work :(

Can anybody help me resolve this problem?
 
Howdy,

It's been a little over a month, so I imagine you've figured this out by now. But, for future reference, here's the deal.

The exception raised in this case is raised at the application level (I believe this is due to the threading that's involved with socket communication), and can only be handled by implementing the Application's OnException handler, like so:

procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnException := MainException;
end;

procedure TMainForm.MainException(Sender: TObject; E: Exception);
begin
if ( E is ESocketError) then begin
{ do spiffy stuff here, possibly
with Exception.Message }
end;
end;

HTH

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top