PDA

View Full Version : QHttp and readyRead signals emit sequence



balitong
15th June 2006, 10:10
Hi all,

I'm trying to use QHttp as a client to send to multiple host. What I currently has is one QHttp instance, with the signal readyRead connected to a slots read_slot, and I want to be able to use this one instance to send to multiple http hosts.

A code excerpt as follows: (this code has not been tested, so there might be some syntax error but the idea is there)

int i=0;
QHttp *httphdl = 0;
char hostname[30]={0};

httphdl = new QHttp(0);

connect(httphdl, SIGNAL(readyRead(const QHttpResponseHeader &)), this, SLOT(slot_readyRead(const QHttpResponseHeader &)));

for (i=0; i < 10; i++)
{
sprintf(hostname, "www.foo%d.bar" , i);
httphdl->setHost(hostname);
httphdl->post("register.html", data);
}

The function works fine. However, if any of the server response slowly, then it would block the others servers and would only get the data after the pending server has timed out or responded.

For example, if i post to server foo1 and foo2, if foo1 response after 5 seconds and foo2 response after 1 seconds. The slot for readyRead would only be called after 5 seconds and process in sequential order, i.e received foo1 response then only receive foo2 response.

What i wish to accomplish is to be able to receive the responses regardless of the sequence that the post request is called. Has anyone done this before? Is that even possible in current implementation of QT?

Thanks in advance.

wysota
15th June 2006, 10:28
Is that even possible in current implementation of QT?
It's Qt and not QT :)

Yes, it's possible. Simply use separate instances of QHttp for different servers.

balitong
15th June 2006, 10:54
Thanks for the reply. I would try to do that.

However, my application would need to send to about 50 hosts at 10 post/sec each, I'm worrying about the performance of instantiating so many QHttp and freeing the memory.

What my application does is to read a list of data from database table and then send to separate hosts depending on an id. The host is only known at runtime. And this application would need to stay on for 24x7. Whenever there is data in the table, it would need to process and send to hosts.

Have anyone ran a load test on the performance of QHttp? Is there any other http libraries that you could recommend? I'm a newbie in the world of HTTP, so please forgive my ignorance. I would try to do a load test and ran the application for a few days with the new changes to see the performance though.

Thank you.

wysota
15th June 2006, 11:14
However, my application would need to send to about 50 hosts at 10 post/sec each, I'm worrying about the performance of instantiating so many QHttp and freeing the memory.
You can store once initialised objects and reuse them later instead of freeing them.

Don't you think sending 500 requests per second might be considered flooding the network?



Have anyone ran a load test on the performance of QHttp? Is there any other http libraries that you could recommend?
If any, then libcurl, but I doubt you'll get better performance. It processes requests sequentially too, afaik.


I'm a newbie in the world of HTTP, so please forgive my ignorance. I would try to do a load test and ran the application for a few days with the new changes to see the performance though.

I'm sure QHttp will suffice.

balitong
19th June 2006, 05:22
Hi,

I've tried your suggestion and it works fine. Thanks for the tip.

the 10 post/sec is for the total throughput, not 10 post/sec each as I've mentioned. This is an application to push user request coming in from another network to the client's http server.