🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Reading a TIdTCPClient connection

#5369
From: Alfred Thomas
Date: Mon, 23 Aug 2004 14:13
38 lines
1862 bytes
Hi all

I want to know what the best way of reading a TIdTCPClientConnection is, I am using the following code in a Timer event:
 char * Buffer = NULL;
 try
 {
  try
  {
   Timer1->Enabled = false;
   IdTCPClient->ReadFromStack(false,100,false);
   TMemoryStream *pStrm = IdTCPClient->InputBuffer;
   if(pStrm->Size > 0 )
   {
    Buffer = new char[pStrm->Size + 1];
    ZeroMemory(Buffer,pStrm->Size + 1);
    pStrm->Position = 0;
    pStrm->Read(Buffer, pStrm->Size);
    pStrm->Clear();
    ShowMessage(Buffer);
   }
  }
  catch(Exception &E)
  {
   ShowMessage(E.Message);
  }
 }
 __finally
 {
  delete [] Buffer;
  Timer1->Enabled = true;
 }

The problem is that when I move the app window around, it is not smooth - I think ReadFromStack causes it. When I reduce the time-out, it doesnt notice when data is sent to the socket.
My understanding is that I need the following to see when data is available for reading:
1) a TIdTCPClient
2) a Timer
3) Do ReadFromStack in the timer
Technical Details
Message-ID: <4129fb81$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,44da35027316a3a0,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alfred Thomas" <alfred@fischerint.co.za>
Sender: "Alfred Thomas" <alfred@fischerint.co.za>
Reply-To: "Alfred Thomas" <alfred@fischerint.co.za>
Subject: Reading a TIdTCPClient connection
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 196.25.217.126     
X-Forwarded-For: 192.96.150.59
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4129fb81$1@newsgroups.borland.com>
Date: 23 Aug 2004 07:13:21 -0700
X-Trace: newsgroups.borland.com 1093270401 207.105.83.66 (23 Aug 2004 07:13:21 -0700)
Lines: 38
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail