🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
1 messages
1 total messages Started by Alfred Thomas Mon, 23 Aug 2004 14:13
Reading a TIdTCPClient connection
#5369
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads