Thread View: borland.public.cppbuilder.internet.web
9 messages
9 total messages
Started by Steffan Kahn
Mon, 01 Nov 2004 17:52
nmhttp - different between timeout and failure
Author: Steffan Kahn
Date: Mon, 01 Nov 2004 17:52
Date: Mon, 01 Nov 2004 17:52
17 lines
1124 bytes
1124 bytes
hello,
when is use following code to call ab website:
try
{
HTTP->Get(Url);
}
catch (...)
{
// time out or failure?
}
how can i determine whether i get an timeout or an failure if there are any
problems. i couldn find anything in the news groups archiv.
steffan
Re: nmhttp - different between timeout and failure
Author: Remy Lebeau (TeamB)
Date: Mon, 01 Nov 2004 18:15
Date: Mon, 01 Nov 2004 18:15
37 lines
1801 bytes
1801 bytes
"Steffan Kahn" <s_kahn@yahoo.com> wrote in message
news:41867801@newsgroups.borland.com...
> when is use following code to call ab website:
<snip>
> how can i determine whether i get an timeout or
> an failure if there are any problems.
By not using "..." in your catch statement to begin with. You can't get
*any* error information by using that. You should be catching specific
Exception types instead, then you can check to see what type of exception is
being thrown, ie:
try
{
HTTP->Get(Url);
}
const (const EIdConnectException &e)
{
// connection timeout...
}
catch (const EIdReadTimeout &e)
{
// reading timeout...
}
catch (const EIdException &e)
{
// any Indy exception...
}
catch (const Exception &e)
{
// any VCL exception...
}
Gambit
Re: nmhttp - different between timeout and failure
Author: Steffan Kahn
Date: Mon, 01 Nov 2004 20:23
Date: Mon, 01 Nov 2004 20:23
52 lines
2226 bytes
2226 bytes
Hi,
problem is that i am not working with indy components. i am using nmhttp
which is inside my bcb5. your exmaple looks like indy example.
is it also possible for nmhttp do decide whether there is an timeout or an
connection problem?
Steffan
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:41867cf2$1@newsgroups.borland.com...
>
> "Steffan Kahn" <s_kahn@yahoo.com> wrote in message
> news:41867801@newsgroups.borland.com...
>
> > when is use following code to call ab website:
> <snip>
> > how can i determine whether i get an timeout or
> > an failure if there are any problems.
>
> By not using "..." in your catch statement to begin with. You can't get
> *any* error information by using that. You should be catching specific
> Exception types instead, then you can check to see what type of exception
is
> being thrown, ie:
>
> try
> {
> HTTP->Get(Url);
> }
> const (const EIdConnectException &e)
> {
> // connection timeout...
> }
> catch (const EIdReadTimeout &e)
> {
> // reading timeout...
> }
> catch (const EIdException &e)
> {
> // any Indy exception...
> }
> catch (const Exception &e)
> {
> // any VCL exception...
> }
>
>
> Gambit
>
>
Re: nmhttp - different between timeout and failure
Author: Remy Lebeau (TeamB)
Date: Mon, 01 Nov 2004 21:20
Date: Mon, 01 Nov 2004 21:20
26 lines
1687 bytes
1687 bytes
"Steffan Kahn" <s_kahn@yahoo.com> wrote in message news:41869b58$1@newsgroups.borland.com... > problem is that i am not working with indy components. Sorry, I did not see that earlier. > i am using nmhttp which is inside my bcb5. I strongly suggest not using the Netmaster components at all. They are very buggy and problematic in general. > your exmaple looks like indy example. It is. > is it also possible for nmhttp do decide whether there is an timeout or an > connection problem? I still suggest that you not use "..." to begin with. Catch the Exception class directly. Then you can find out what type of exception is being thrown and adjust your code accordingly. Gambit
Re: nmhttp - different between timeout and failure
Author: Steffan Kahn
Date: Mon, 01 Nov 2004 22:08
Date: Mon, 01 Nov 2004 22:08
44 lines
2240 bytes
2240 bytes
Hi, at this application i like to stay at nmhttp. i looked into the vcl help file and also in the help for nmhttp. but i can't anywhere find out information how to differentiate between a timeout and an error. furthermore i couldn't find any information in the exceptionen classes help. there should be any way, but how? steffan "Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag news:4186a83f$1@newsgroups.borland.com... > > "Steffan Kahn" <s_kahn@yahoo.com> wrote in message > news:41869b58$1@newsgroups.borland.com... > > > problem is that i am not working with indy components. > > Sorry, I did not see that earlier. > > > i am using nmhttp which is inside my bcb5. > > I strongly suggest not using the Netmaster components at all. They are very > buggy and problematic in general. > > > your exmaple looks like indy example. > > It is. > > > is it also possible for nmhttp do decide whether there is an timeout or an > > connection problem? > > I still suggest that you not use "..." to begin with. Catch the Exception > class directly. Then you can find out what type of exception is being > thrown and adjust your code accordingly. > > > Gambit > >
Re: nmhttp - different between timeout and failure
Author: Remy Lebeau (TeamB)
Date: Mon, 01 Nov 2004 22:21
Date: Mon, 01 Nov 2004 22:21
45 lines
2174 bytes
2174 bytes
"Steffan Kahn" <s_kahn@yahoo.com> wrote in message
news:4186b3ec@newsgroups.borland.com...
> at this application i like to stay at nmhttp. i looked into
> the vcl help file and also in the help for nmhttp. but i can't
> anywhere find out information how to differentiate between
> a timeout and an error.
I already told you what to do. Change your code to catch the Exception
class instead of "..." and then query the Exception to find out what it
actualy is when things occur. For example:
try
{
HTTP->Get(Url);
}
catch (const Exception &e)
{
ShowMessage(e.ClassName());
}
Once you know which types of exceptions are thrown, you can update your code
acordingly:
try
{
HTTP->Get(Url);
}
catch (const ExceptionTypeWhenATimeoutOccured &e)
{
//...
}
catch (const ExceptionTypeWhenAnErrorOccured &e)
{
//...
}
> furthermore i couldn't find any information in the
> exceptionen classes help.
Third party exceptions are not documented at all, especially Netmasters'.
Gambit
Re: nmhttp - different between timeout and failure
Author: Steffan Kahn
Date: Mon, 01 Nov 2004 23:38
Date: Mon, 01 Nov 2004 23:38
80 lines
3154 bytes
3154 bytes
hi,
as i couldn't find what ExceptionType is thrown for the timeout ( i search
in the borland newsgroups, google and the website of the netmaster) i wrote
a little test application with the code you gave me:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
try
{
HTTP1->Get("http://www.borland.com");
}
catch (const Exception &e)
{
ShowMessage(e.ClassName());
}
}
To get a timeout i set Timeout = 1; Then the exception shows ESockError.
Then i switch Timeout back to 0 and tried to open a webpage which doesn't
exist. i also get a ESockError. I always get ESockError. So there might be
none possibility to differentiate between timeout and connection error.
i have no more ideas what to do.
steffen
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:4186b68f$1@newsgroups.borland.com...
>
> "Steffan Kahn" <s_kahn@yahoo.com> wrote in message
> news:4186b3ec@newsgroups.borland.com...
>
> > at this application i like to stay at nmhttp. i looked into
> > the vcl help file and also in the help for nmhttp. but i can't
> > anywhere find out information how to differentiate between
> > a timeout and an error.
>
> I already told you what to do. Change your code to catch the Exception
> class instead of "..." and then query the Exception to find out what it
> actualy is when things occur. For example:
>
> try
> {
> HTTP->Get(Url);
> }
> catch (const Exception &e)
> {
> ShowMessage(e.ClassName());
> }
>
> Once you know which types of exceptions are thrown, you can update your
code
> acordingly:
>
> try
> {
> HTTP->Get(Url);
> }
> catch (const ExceptionTypeWhenATimeoutOccured &e)
> {
> //...
> }
> catch (const ExceptionTypeWhenAnErrorOccured &e)
> {
> //...
> }
>
> > furthermore i couldn't find any information in the
> > exceptionen classes help.
>
> Third party exceptions are not documented at all, especially Netmasters'.
>
>
> Gambit
>
>
Re: nmhttp - different between timeout and failure
Author: Remy Lebeau (TeamB)
Date: Tue, 02 Nov 2004 00:50
Date: Tue, 02 Nov 2004 00:50
19 lines
1852 bytes
1852 bytes
"Steffan Kahn" <s_kahn@yahoo.com> wrote in message news:4186c8f7@newsgroups.borland.com... > To get a timeout i set Timeout = 1; Then the exception shows > ESockError. Then i switch Timeout back to 0 and tried to > open a webpage which doesn't exist. i also get a ESockError. > I always get ESockError. So there might be none possibility > to differentiate between timeout and connection error. You will just have to manually parse the Exception's Message property to decide what happened. Or, you can do as I alreadyy suggested earlier and not use TNMHTTP to begin with, but instead switch to a different component which gives you more control over what happens and what is reported to you. Gambit
Re: nmhttp - different between timeout and failure
Author: Steffan Kahn
Date: Tue, 02 Nov 2004 00:57
Date: Tue, 02 Nov 2004 00:57
33 lines
2140 bytes
2140 bytes
hi, with the use of the message i will be able to solve my problems. thanks very much steffen "Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag news:4186d9b2$1@newsgroups.borland.com... > > "Steffan Kahn" <s_kahn@yahoo.com> wrote in message > news:4186c8f7@newsgroups.borland.com... > > > To get a timeout i set Timeout = 1; Then the exception shows > > ESockError. Then i switch Timeout back to 0 and tried to > > open a webpage which doesn't exist. i also get a ESockError. > > I always get ESockError. So there might be none possibility > > to differentiate between timeout and connection error. > > You will just have to manually parse the Exception's Message property to > decide what happened. > > Or, you can do as I alreadyy suggested earlier and not use TNMHTTP to begin > with, but instead switch to a different component which gives you more > control over what happens and what is reported to you. > > > Gambit > >
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