Results 1 to 5 of 5

Thread: QHttp and readyRead signals emit sequence

  1. #1
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QHttp and readyRead signals emit sequence

    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)
    [HTML]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);
    }[/HTML]

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp and readyRead signals emit sequence

    Quote Originally Posted by balitong
    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.

  3. #3
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp and readyRead signals emit sequence

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp and readyRead signals emit sequence

    Quote Originally Posted by balitong
    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.

  5. #5
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp and readyRead signals emit sequence

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.