🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Winsock error

#3071
From: Remy Lebeau (TeamB)
Date: Thu, 01 Dec 2005 18:39
38 lines
2041 bytes
"Okusmen" <okusmen@aselsan.com.tr> wrote in message
news:438ecb2f$1@newsgroups.borland.com...

>         try{
>                   SendSocket->Open();
>         }catch(const Exception &e){
>          CloseSendSocket();
>  }

That won't always work.  When Open() throws an exception, it can leave the
socket in an indeterminate state that Close() does not fully recover from.
You would be better off just freeing the TClientSocket object and then
reinstantiate it.  That ensures that all resources are fully released.

>       SendSocket->Close();
>       SendSocket->Port = 0;
>       SendSocket->Active = false;

Why are you closing the socket twice?

> void __fastcall TTCPSendDataModule::SendSocketError(TObject */*Sender*/,
>       TCustomWinSocket */*Socket*/, TErrorEvent /*ErrorEvent*/, int
&ErrorCode)
> {
>  try
>     {
>      ErrorCode = 0;
>     CloseSendSocket();
>  }catch(const Exception &e){
>  }
> }

You should be caling Close() on the Socket parameter, not the TClientSocket
object directly.


Gambit
Technical Details
Message-ID: <438f4384$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <438b17b9@newsgroups.borland.com> <438be864$1@newsgroups.borland.com> <438ecb2f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,f5adeb6c598c786f
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <438b17b9@newsgroups.borland.com> <438be864$1@newsgroups.borland.com> <438ecb2f$1@newsgroups.borland.com>
Subject: Re: Winsock error
Date: Thu, 1 Dec 2005 10:39:09 -0800
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <438f4384$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1133462404 68.69.17.41 (1 Dec 2005 10:40:04 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!meganewsservers.com!feeder2.on.meganewsservers.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail