🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: initialising a ClientSocket

#4960
From: Vladimir Stefanovic
Date: Mon, 22 Nov 2004 17:35
53 lines
2541 bytes
>  I think it works but the messages just did not get
> carried out.  So I got round this by calling
> Application->ProcessMessages() just after I set up
> the client connection and now it workes fine.

Sometimes it can be smart to place the sending code
in OnActivate(), and not immediately after the Open().

That means, instead of:

   ClientSocket1->Active = true;
   SendData();

you can use:

   ClientSocket->Active = true;

   void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
         TCustomWinSocket *Socket)
   {
      SendData();
   }

If you prefer the first way, from my experience I think
that only one Application->ProcessMessages() may not
be enough every time. Then you can do something like:


   ClientSocket1->Active = true;
   // waits max one secend for connection...
   int ms_start = GetTickCount();
   while ( GetTickCount() - ms_start < 1000 )
   {
      Application->ProcessMessages();
      if ( ClientSocket1->Active )
         break;
   }

   if ( !ClientSocket1->Active )
   {
      // Force stopping ...
      ClientSocket1->Active = false;
      // Handle error...
   }
   else
   {
      SendData();
   }



Best regards,
Vladimir Stefanovic
Technical Details
Message-ID: <41a22386@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41938125$1@newsgroups.borland.com> <4193a0bb@newsgroups.borland.com> <41989b78$1@newsgroups.borland.com> <4198a148$1@newsgroups.borland.com> <4198aed9$1@newsgroups.borland.com> <4198b1a6$1@newsgroups.borland.com> <4198be15@newsgroups.borland.com> <4198cb39$1@newsgroups.borland.com> <4198cf03$1@newsgroups.borland.com> <4198d30f$1@newsgroups.borland.com> <419b5a36$1@newsgroups.borland.com> <41a1cceb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,f81efd77741cef0b
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Vladimir Stefanovic" <spam@not.needed>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41938125$1@newsgroups.borland.com> <4193a0bb@newsgroups.borland.com> <41989b78$1@newsgroups.borland.com> <4198a148$1@newsgroups.borland.com> <4198aed9$1@newsgroups.borland.com> <4198b1a6$1@newsgroups.borland.com> <4198be15@newsgroups.borland.com> <4198cb39$1@newsgroups.borland.com> <4198cf03$1@newsgroups.borland.com> <4198d30f$1@newsgroups.borland.com> <419b5a36$1@newsgroups.borland.com> <41a1cceb$1@newsgroups.borland.com>
Subject: Re: initialising a ClientSocket
Date: Mon, 22 Nov 2004 18:35:15 +0100
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
NNTP-Posting-Host: 213.137.127.169
Message-ID: <41a22386@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1101144966 213.137.127.169 (22 Nov 2004 09:36:06 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail