Thread View: borland.public.cppbuilder.internet.socket
5 messages
5 total messages
Started by emerson.pardo
Thu, 03 May 2007 18:55
TIdHTTPClient read blocking when keep-alive is enabled
Author: emerson.pardo
Date: Thu, 03 May 2007 18:55
Date: Thu, 03 May 2007 18:55
20 lines
1703 bytes
1703 bytes
Hi all,
I'm trying to create a client with keep-alive enabled but when I do
the request the app blocks. Here the code snippet (IdHTTP is a
TIdHTTPClient*):
...
IdHTTP -> ProtocolVersion << pv1_1;
IdHTTP -> Request -> Connection = "keep-alive";
IdHTTP -> Request -> ProxyConnection = "keep-alive";
IdHTTP -> Response -> KeepAlive = true;
AnsiString response = IdHTTP -> Get("http://localhost:81"); //
it blocks here
...
I've already tried with Post and with DoRequest. Both blocks too.
What am I doing wrong?
Thanks in advance!
Re: TIdHTTPClient read blocking when keep-alive is enabled
Author: emerson.pardo
Date: Fri, 04 May 2007 20:14
Date: Fri, 04 May 2007 20:14
25 lines
2007 bytes
2007 bytes
I've forgot to say that the Indy version I'm using is 9.0.18.
[]s
On 3 maio, 15:55, emerson.pa...@gmail.com wrote:
> Hi all,
>
> I'm trying to create a client with keep-alive enabled but when I do
> the request the app blocks. Here the code snippet (IdHTTP is a
> TIdHTTPClient*):
>
> ...
> IdHTTP -> ProtocolVersion << pv1_1;
> IdHTTP -> Request -> Connection = "keep-alive";
> IdHTTP -> Request -> ProxyConnection = "keep-alive";
> IdHTTP -> Response -> KeepAlive = true;
> AnsiString response = IdHTTP -> Get("http://localhost:81"); //
> it blocks here
> ...
>
> I've already tried with Post and with DoRequest. Both blocks too.
>
> What am I doing wrong?
>
> Thanks in advance!
Re: TIdHTTPClient read blocking when keep-alive is enabled
Author: emerson.pardo
Date: Mon, 07 May 2007 16:09
Date: Mon, 07 May 2007 16:09
48 lines
2590 bytes
2590 bytes
Solved.
Here the solution (simplified) I've coded:
...
IdHTTP -> ProtocolVersion << pv1_1;
IdHTTP -> Request -> Connection = "keep-alive";
IdHTTP -> Request -> ProxyConnection = "keep-alive";
IdHTTP -> Response -> KeepAlive = true;
// next lines replace IdHTTP -> Get("http://localhost:81")
IdHTTP -> Host = "localhost";
IdHTTP -> Port = 81;
IdHTTP -> Connect(100);
IdHTTP -> Write("GET / \n\n");
AnsiString line = IdHTTP -> ReadLn("\n", 100, 500);
while(IdHTTP -> Connected())
{
if(line . Length() > 0)
{
// process line
}
::Sleep(100);
line = IdHTTP -> ReadLn("\n", 100, 500);
}
...
[]s
On 3 maio, 15:55, emerson.pa...@gmail.com wrote:
> Hi all,
>
> I'm trying to create a client with keep-alive enabled but when I do
> the request the app blocks. Here the code snippet (IdHTTP is a
> TIdHTTPClient*):
>
> ...
> IdHTTP -> ProtocolVersion << pv1_1;
> IdHTTP -> Request -> Connection = "keep-alive";
> IdHTTP -> Request -> ProxyConnection = "keep-alive";
> IdHTTP -> Response -> KeepAlive = true;
> AnsiString response = IdHTTP -> Get("http://localhost:81"); //
> it blocks here
> ...
>
> I've already tried with Post and with DoRequest. Both blocks too.
>
> What am I doing wrong?
>
> Thanks in advance!
Re: TIdHTTPClient read blocking when keep-alive is enabled
Author: Remy Lebeau (TeamB)
Date: Mon, 07 May 2007 17:23
Date: Mon, 07 May 2007 17:23
20 lines
1577 bytes
1577 bytes
<emerson.pardo@gmail.com> wrote in message
news:1178554180.638229.240770@e65g2000hsc.googlegroups.com...
> IdHTTP -> ProtocolVersion << pv1_1;
ProtocolVersion is not a Set. You need to use the '=' operator
instead:
IdHTTP -> ProtocolVersion = pv1_1;
> // next lines replace IdHTTP -> Get("http://localhost:81")
Why are you replacing Get()? You should not be doing that at all.
You are completely bypassing everything TIdHTTP handles for you about
the HTTP protocol. Your code is much to minimal to handle HTTP
properly.
Gambit
Re: TIdHTTPClient read blocking when keep-alive is enabled
Author: emerson.pardo
Date: Mon, 07 May 2007 18:00
Date: Mon, 07 May 2007 18:00
29 lines
2374 bytes
2374 bytes
On 7 maio, 14:23, "Remy Lebeau \(TeamB\)" <no.s...@no.spam.com> wrote:
> <emerson.pa...@gmail.com> wrote in message
>
> news:1178554180.638229.240770@e65g2000hsc.googlegroups.com...
>
> > IdHTTP -> ProtocolVersion << pv1_1;
>
> ProtocolVersion is not a Set. You need to use the '=' operator
> instead:
>
> IdHTTP -> ProtocolVersion = pv1_1;
Oops! Thanks!
> > // next lines replace IdHTTP -> Get("http://localhost:81")
>
> Why are you replacing Get()? You should not be doing that at all.
> You are completely bypassing everything TIdHTTP handles for you about
> the HTTP protocol. Your code is much to minimal to handle HTTP
> properly.
My server produce data asynchronously and I need my client to keep
connected and consume the data when it is available (in my code sample
I check this availability every 100 ms). I search for an IO event
handler but I didn't find any. So I coded the solution above. If there
is some better solution I'll be glad to know it! :-)
Thanks again,
Emerson
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