🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3322

TClientSocket and error events

#3322
From: Stormy
Date: Thu, 13 Oct 2005 23:27
35 lines
2572 bytes
Greetings,

I have a small problem with client socket. If I set its Host property to an
unknown host and activate it (either by Open() method or by setting it's
Active property to true), application throws an exception which is handled
inside my handler:
...
Application->OnException = AppException;
...
void __fastcall TForm1::AppException(TObject *Sender, Exception *E)
{
TClientWinSocket *sckt1 = dynamic_cast< TClientWinSocket * >(Sender);
if (sckt1) { ...log error... check if active... }
...
}

When reading socket's Active property inside the exception handler above, it
reads false, which means socket is closed or in process of being closed.

Now, the problem is when I now set socket's Host property to existing,
running host, and open the connection, instead of connecting it throws an
error via OnError event. Error is, of course, related to prior connection
failure to unknown host. OnError event simply does not occur after exception
being thrown. Exception message is: "Windows socket error: No such host is
known (11001), on API 'ASync Lookup'" and ErrorCode inside OnError event is
#10049.

Is there any way of resetting ErrorCode inside exception handler, and if so,
would it prevent socket from triggering an OnError event? My current
solution involves setting socket's Active property back to true inside
exception handler what causes OnError event to occur for given unknown host
connection (I moved error logging inside OnError event), but this just
doesn't seem to be the right way to solve this problem.

Thank you.
Technical Details
Message-ID: <434eecdf@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!fr.ip.ndsoftware.net!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,bc23240211b4e678,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Stormy" <s70rmy@hotmail.com>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: TClientSocket and error events
Date: Fri, 14 Oct 2005 01:27:32 +0200
Lines: 36
MIME-Version: 1.0
Content-Type: text/plain;
 charset="iso-8859-2"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 193.198.130.64
Message-ID: <434eecdf@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1129245919 193.198.130.64 (13 Oct 2005 16:25:19 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!fr.ip.ndsoftware.net!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail