I don't know if there's a better way
That is fine.
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be
----- Original Message -----
From: "Daniele Rocchi" <desroc...@gmail.com>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Monday, April 11, 2011 2:34 PM
Subject: Re: [twsocket] THttpCli not returning?
It has happened to me too, I don't know if there's a better way to
deal with it, but all I do is create a "timeout" timer that is set to
start at the beginning of a get() and to stop at the end of the Get()
request.
If the timer reaches 0 before the Get() is completed I abort the
operation and the program goes on its way, I usually give it 60
seconds.
Daniele
On 11 April 2011 13:17, David Lewis <dave.le...@simulation-systems.co.uk>
wrote:
I have an application that retrieves a single image over HTTP from a video
server every 60 seconds. This is does over GPRS so at times can be a
little
slow, but in general there are no issues.
I'm using the THttpCli component to get the Get( ) the images within
BDS2006, C++ flavour.
However, very occasionally I am seeing that my method that gathers these
images never finishes, and I'm pretty sure the cause is the Get( ) method
in
the THttpCli.
No exception is thrown, but the method just never returns, and therefore
the
method hangs indefinitely. (2 days and counting)
Is this 'normal' behaviour? Can it be detected and dealt with?
The basic operation of what I'm doing is this:
void __fastcall cImageCaptureClass::me_TimeoutTimerTimer(TObject *Sender)
{
cLoggerClass * cl_LoggerClass = cLoggerClass::Instance( ); // Logger
Singleton
try
{
// Set the HTTP paramaters ready for connection
co_HttpClient->Location = at_FileName;
co_HttpClient->Username = at_UserName;
co_HttpClient->Password = at_Password;
co_HttpClient->URL = "http://" + at_SnapshotIP +
"/axis-cgi/jpg/image.cgi?streamprofile=" + at_ImageProfile;
co_HttpClient->Connection = "Keep-Alive";
co_HttpClient->Get( );
if (IntToStr(co_HttpClient->StatusCode) == 200) // The only code that
matters to me
{
cl_LoggerClass->me_AddLog("Snapshot Status: 200 OK",
cLoggerClass::LOG_TYPE_SUCCESS, cLoggerClass::LOG_LEVEL_RELEASE);
// A valid reply? Ok, so delete the old image, and copy this temp
file as the new image
try
{
if (FileExists(at_FinalFileName)) // We have an old image?
{
DeleteFile(at_FinalFileName); // Remove old image
} // else nothing to remove
CopyFile(at_FileName.c_str( ), at_FinalFileName.c_str( ),
false); // Copy new image
}
catch ( ... ) // File Delete/Copy failed. Doesn't matter why.
{
cl_LoggerClass->me_AddLog("Snapshot: Error updating new
file!", cLoggerClass::LOG_TYPE_ERROR, cLoggerClass::LOG_LEVEL_RELEASE);
}
}
else // Not 200 reply? Something failed then. Doesn't really matter
what.
{
cl_LoggerClass->me_AddLog("Snapshot: Aborted with Status: " +
IntToStr(co_HttpClient->StatusCode) + " ERROR",
cLoggerClass::LOG_TYPE_ERROR, cLoggerClass::LOG_LEVEL_RELEASE);
}
}
catch ( ... ) // co_HttpClient->Get( ) failed. Doesn't matter why.
{
cl_LoggerClass->me_AddLog("Snapshot: Can't Get: " +
IntToStr(co_HttpClient->StatusCode) + " ERROR",
cLoggerClass::LOG_TYPE_ERROR, cLoggerClass::LOG_LEVEL_RELEASE);
}
}
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be