🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages Started by bar Sat, 22 Mar 2008 17:55
indy question
#355
Author: bar
Date: Sat, 22 Mar 2008 17:55
81 lines
3172 bytes
I am using indy 9 with BCB6.0

I want to download some xml files in stream format.

TldHTTP component dropped on the main form with properties
HandleRedirects = true;
Connection = Keep-Alive;
CacheControl = no-cache;
ConnectTimeout = 0;

//Header file
TMemoryStream *XMLStream;
String ErrorStream;

TDateTime ReceivedTime,TakeTime;
long int 
TotalPackets,OneTimeReceivedPackets,PreviousPackets,Duration,TrasferRate;


//Cpp file.
void TfrmMain::DownloadStream(String URL)
{
    try
    {
        ErrorStream = "";
        HTTP->Get(URL, XMLStream);
    }
    catch(const Exception &E)
    {
         if(HTTP->Connected())
                 HTTP->Disconnect();

         ErrStream = E.Message;
    }
}

//I am displaying a progress bar
void __fastcall TfrmMain::HTTPConnected(TObject *Sender)
{
    Application->ProcessMessages();
    this->Update();
    lblDownloadStatus->Caption = "Connected.";
}
//---------------------------------------------------------------------------

void __fastcall TfrmMain::HTTPWorkBegin(TObject *Sender,
      TWorkMode AWorkMode, const int AWorkCountMax)
{
    Application->ProcessMessages();
    this->Update();

    ProgressBar1->Position = 0;
    ProgressBar1->Max = AWorkCountMax;
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::HTTPWork(TObject *Sender, TWorkMode AWorkMode,
      const int AWorkCount)
{
    Application->ProcessMessages();
    this->Update();

    ProgressBar1->Position = AWorkCount;
    ProgressBar1->Update();
//---------------------------------------------------------------------------

As i TldHTTP dropped in GUI form. It is blocking the GUI messages but i 
don't have any problem when the internet speed and server is response is 
good.

I have the following problem.
1.When the server is busy it is waiting for something 10-15 seconds and then 
raising the exception.
2.And some times the form is freezing and form is not responding.

Questions
1. Have anybody experienced this problem. Why the same code is not 
responding at some occasions.
2. Even if responding its taking time, can we make it active, reduce the 
checking time.
3  Setting ConnectTimeout can make any difference, does it work in this 
case. 
Re: indy question
#357
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Mar 2008 16:31
26 lines
1800 bytes
"bar" <shaikakbar250281@yahoo.co.in> wrote in message 
news:47e547f8@newsgroups.borland.com...

>    Application->ProcessMessages();
>    this->Update();

Rather than doing that in each event handler, put a separate TIdAntiFreeze 
component onto the TForm instead.

> 1.When the server is busy it is waiting for something 10-15
> seconds and then raising the exception.

That is normal.  The only thing you can do about that is to set the 
ReadTimeout property.

> 2.And some times the form is freezing and form is not responding.

Because there are no event handlers being triggered yet so your code can 
call Application->ProcessMessages().  All the more reason for you to use the 
TIdAntiFreeze component instead.  Indy calls into that internally during 
blocking operations, so it will be able to call ProcessMessages() more often 
then your own code is able to.


Gambit 
Re: indy question
#362
Author: bar
Date: Tue, 25 Mar 2008 13:50
5 lines
914 bytes
Thanks remy.
I'll test it.

:)
SA 
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