🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ESocketError

#5288
From: Remy Lebeau [TeamB]
Date: Sat, 18 Sep 2004 04:33
27 lines
1834 bytes
"JD" <nospam@nospam.com> wrote:

> Why can't I catch ESocketError?

Are you using the socket in non-blocking mode?  If so, then
the actual work of Open() is being executed long after your
code flow has already flowed past your error handling code
altogether, thus it is no longer available to catch errors.
In which case, you should be using the socket's OnError event
instead to handle the error.  You can set the ErrorCode
parameter to 0 to prevent the eception from being thrown in
the first place after you handle the error.  For example:

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
        ClientSocket1->Open();
    }

    void __fastcall TForm1::ClientSocket1Error(TObject *Sender, TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
    {
        MessageDlg("Socket Error: " + AnsiString(ErrorCode), mtError, TMsgDlgButtons() << mbOK, 0 );
        ErrorCode = 0;
    }


Gambit
Technical Details
Message-ID: <414bba83$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <414b8772$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,2a74cb97a91b535d
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau [TeamB]" <gambit47_no_spam@yahoo_no_spam.com>
Sender: "Remy Lebeau [TeamB]" <gambit47_no_spam@yahoo_no_spam.com>
Reply-To: "Remy Lebeau [TeamB]" <gambit47_no_spam@yahoo_no_spam.com>
Subject: Re: ESocketError
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 206.107.212.103     
References:  <414b8772$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <414bba83$1@newsgroups.borland.com>
Date: 17 Sep 2004 21:33:07 -0700
X-Trace: newsgroups.borland.com 1095481987 207.105.83.66 (17 Sep 2004 21:33:07 -0700)
Lines: 27
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail