Results 1 to 17 of 17

Thread: qt network performance

  1. #1
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy qt network performance

    hi to all,

    i'm using qt 4.1.x with vs7.1 (2003 version) on winxp.

    i've coded the following: a (qtcp)server and clients over qtcpsocket. both are gui applications (because of easier displaying any data . the server "accepts" clients, holts on-/offline status of all clients (ok, at the moment just 2), sends data from one client (lets say generator-client) to the other client (consumer-client). for each client/server connection i'm opening only one qtcpsocket with readwrite access. using a start-command the generator-client produces some double values, until the server send a stop-command. for sending/receiving data to/from a socket, i'm using a qdatastream. all send operations are finished with a flush().

    now, the generator is sending every 5ms 3 double values to the server and the server forwards it to the consumer. when i run everything on one pc, everything works fine. all data are fast received.

    but if i'm using for example 2 pc's (connected over a 100mbit hub/switch, nothing else), whereas the server/clients are started in different combinations on the pc's, then only 5-7 (approx all 20ms) messages are received form the server. the rest is getting lost.

    what i'm or qt (also read posts about qt's performance problems) or windows is making wrong? i need all information, that is produced through my generator-client. will be the transfer using udp packages faster? should i use fewer socket-connections (one for read only, one for write only)? should i use another network package (winsock, raknet, ...) than qnetwork?

    any hint would be appreciated?

    regards

    criss
    Last edited by criss; 18th July 2006 at 12:48. Reason: bug fix :)

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

    Default Re: qt network performance

    Could we see some code? Does anything weird happen? Do those messages which are sent get to the consumer successfully? It looks like you're blocking the network flow (event queue? system buffers?) or something like that.

  3. #3
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Re: qt network performance

    czesz wysota

    nothing weired is happeing, just with a "real" network it's somehow... i don't know. i've know just the server and the generator client for testing running. the server is getting the informations also to slow. i'm also thinking, that something is blocking, but i cannot see anything that causes it.

    ok, here is the implementation for the generator client. this is a simple thread generating some values:

    Qt Code:
    1. void genthread::run()
    2. {
    3. while(!stopgen)
    4. {
    5. x = (rand() % 10) - 5.0f;
    6. y = (rand() % 10) - 5.0f;
    7. z = (rand() % 5) - 2.5f;
    8.  
    9. emit message(tr("sending %1 %2 %3...").arg(QString("%1").arg(x), QString("%1").arg(y), QString("%1").arg(z)));
    10. emit generated(x, y, z);
    11.  
    12. msleep(5);
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    and here is method, which sends the data using a qdatastream, and my readdata() method:

    Qt Code:
    1. void posgen::sendit(double x, double y, double z)
    2. {
    3. ds << tr("posgen");
    4. ds << x << y << z;
    5. socket->flush();
    6. }
    7.  
    8. void posgen::readdata()
    9. {
    10. ds >> inp;
    11.  
    12. if(inp.compare("simctrl") == 0)
    13. {
    14. ds << tr("modulename");
    15. ds << tr("posgen");
    16. }
    17.  
    18. if(inp.compare("start") == 0)
    19. {
    20. if(gen == NULL)
    21. {
    22. gen = new genthread(this);
    23. connect(gen, SIGNAL(message(QString)), this, SLOT(addtolog(QString)));
    24. connect(gen, SIGNAL(generated(double, double, double)), this, SLOT(sendit(double, double, double)));
    25. gen->start();
    26. }
    27. else
    28. {
    29. addtolog("generator is still running");
    30. }
    31. }
    32.  
    33. if(inp.compare("stop") == 0)
    34. {
    35. if(gen != NULL)
    36. {
    37. gen->stopgenthread();
    38. gen = NULL;
    39. }
    40. }
    41.  
    42. if(!inp.isEmpty())
    43. addtolog(inp);
    44. }
    To copy to clipboard, switch view to plain text mode 

    and the server receives the data as following:

    Qt Code:
    1. void connectionhandler::readdata()
    2. {
    3. ds >> inp;
    4.  
    5. if(inp.compare("modulename") == 0)
    6. {
    7. ds >> inp;
    8. emit modulename(inp, nr);
    9. }
    10. else if(inp.compare("posgen") == 0)
    11. {
    12. double x, y, z;
    13. ds >> x >> y >> z;
    14. emit forwardto("imggen", x, y, z);
    15. emit message(tr("posgen> (%1, %2, %3)").arg(QString("%1").arg(x), QString("%1").arg(y), QString("%1").arg(z)));
    16. }
    17. else if(!inp.isEmpty())
    18. emit message(tr("%1: %2").arg(QString("%1").arg(nr), QString("%1").arg(inp)));
    19. }
    To copy to clipboard, switch view to plain text mode 

    the server receives posgen msg, tries to forward the message, if the right client is connected and displays the received values in its own log window. i mean, everything standard code, nothing complicated.

    any idea?

    krzysztof

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

    Default Re: qt network performance

    Czesc

    Can you show the part responsible for establishing connections between the components?

  5. #5
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Re: qt network performance

    ok, connection accept from the server side:

    Qt Code:
    1. void serverhandler::processnewconnection()
    2. {
    3. QTcpSocket *socket = server->nextPendingConnection();
    4. if(socket != 0)
    5. {
    6. cnt++;
    7.  
    8. connectionhandler *c = new connectionhandler(socket, cnt);
    9.  
    10. tostore ts;
    11. ts.nr = cnt;
    12. ts.name = QString("%1").arg(cnt);
    13. ts.p = c;
    14.  
    15. clients.append(ts);
    16.  
    17. emit message(tr("|serverhandler| # clients connected: %1").arg(clients.size()));
    18.  
    19. connect(c, SIGNAL(message(QString)), this, SIGNAL(message(QString)));
    20. connect(c, SIGNAL(disconnect(int)), this, SLOT(clientdisconnected(int)));
    21. connect(c, SIGNAL(modulename(QString, int)), this, SLOT(clientname(QString, int)));
    22. connect(c, SIGNAL(forwardto(QString, double, double, double)), this, SLOT(forwardto(QString, double, double, double)));
    23. }
    24. else
    25. {
    26. emit message("|serverhandler| socket problem. new connection not established.");
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    and here is the part from the generator client:

    Qt Code:
    1. void posgen::connecttoserver()
    2. {
    3. QString address(ui.lineserveraddress->text());
    4. int port = ui.lineserverport->text().toInt();
    5. addtolog(tr("connecting to %1:%2...").arg(address, QString("%1").arg(port)));
    6.  
    7. socket->abort();
    8. socket->connectToHost(address, port, QIODevice::ReadWrite);
    9. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: qt network performance

    Could you check if example network applications that come with Qt work fine? And could you check if the problem persists if you change the thread generating numbers to something like this:

    Qt Code:
    1. void genthread::run(){
    2. QTimer timer;
    3. timer.setInterval(5);
    4. connect(&timer, SIGNAL(timeout()), this, SLOT(generateNumbers()));
    5. timer.start();
    6. exec();
    7. }
    8. void genthread::generateNumbers(){
    9. if(stopgen) QThread::exit();
    10. x = (rand() % 10) - 5.0f;
    11. y = (rand() % 10) - 5.0f;
    12. z = (rand() % 5) - 2.5f;
    13. emit message(tr("sending %1 %2 %3...").arg(QString("%1").arg(x), QString("%1").arg(y), QString("%1").arg(z)));
    14. emit generated(x, y, z);
    15. }
    To copy to clipboard, switch view to plain text mode 

    BTW. With such construction you can get rid of the thread at all and do everything in one thread. It's possible that it's the threading which causes trouble because you didn't have the event loop running (see QThread::exec() for details).

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt network performance

    Quote Originally Posted by criss
    connect(gen, SIGNAL(message(QString)), this, SLOT(addtolog(QString)));
    connect(gen, SIGNAL(generated(double, double, double)), this, SLOT(sendit(double, double, double)));
    If gen is a thread that emits signals, you should force the connection type to Qt::QueuedConnection, otherwise you might have problems.

  8. #8
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Re: qt network performance

    the network examples (fortune, broadcast, ...) working fine locally and over lan.

    ok, i've made the connects queuedconnection, i run the qtimer and entered qt's event loop. finally i omitted the genthread and put the qtimer and the generatenumbers method to my posgen class. and again, if i run everything locally (on one pc), i'm receiving all data and fast. but over lan (with a switch in between) not. ok, i've recognized a small increase in the received message count per second (9-11 messages), but the rest...

    if i run the server and the client app locally, i see another weird behavior: if the server requests the generator-client to stop the generation, not all numbers are received from the server. when i start the number generation again, first the rest of the old data are received, then a portion (or rarely all) of the new data. here is a sample log fragment from the client and server. i tried to get the generated numbers on the same line, to compare it easier. at the end of the log you see, that still numbers are send, but not received.

    any more hints?

    log:

    Qt Code:
    1. client log: server log:
    2.  
    3. <10:38:09> stopping sim...
    4. <10:38:09> sending -2 3 -0.5... <10:38:09> posgen> (-2, 3, -0.5)
    5. <10:38:09> sending -2 4 1.5... <10:38:09> posgen> (-2, 4, 1.5)
    6. <10:38:09> sending 3 0 -1.5... <10:38:09> posgen> (3, 0, -1.5)
    7. <10:38:09> sending -2 -3 0.5... <10:38:09> posgen> (-2, -3, 0.5)
    8. <10:38:09> sending -4 1 1.5... <10:38:22> starting sim...
    9. <10:38:09> sending 1 2 -0.5... <10:38:22> posgen> (-4, 1, 1.5)
    10. <10:38:09> sending 4 1 1.5... <10:38:22> posgen> (1, 2, -0.5)
    11. <10:38:09> sending -4 4 -0.5... <10:38:23> posgen> (4, 1, 1.5)
    12. <10:38:09> sending 1 -2 -1.5... <10:38:23> posgen> (-4, 4, -0.5)
    13. <10:38:09> sending 0 4 -0.5... <10:38:23> posgen> (1, -2, -1.5)
    14. <10:38:09> sending -5 -3 -1.5... <10:38:23> posgen> (0, 4, -0.5)
    15. <10:38:09> sending -4 2 -1.5... <10:38:23> posgen> (-5, -3, -1.5)
    16. <10:38:09> sending -3 0 0.5... <10:38:23> posgen> (-4, 2, -1.5)
    17. <10:38:09> sending -1 -5 -0.5... <10:38:23> posgen> (-3, 0, 0.5)
    18. <10:38:09> sending 0 0 0.5... <10:38:23> posgen> (-1, -5, -0.5)
    19. <10:38:09> sending -4 3 0.5... <10:38:23> posgen> (0, 0, 0.5)
    20. <10:38:09> sending 3 -5 -1.5... <10:38:23> posgen> (-4, 3, 0.5)
    21. <10:38:09> sending 2 0 -2.5... <10:38:23> posgen> (3, -5, -1.5)
    22. <10:38:09> sending 0 4 -2.5... <10:38:23> posgen> (2, 0, -2.5)
    23. <10:38:09> sending 4 -2 -2.5... <10:38:23> posgen> (0, 4, -2.5)
    24. <10:38:09> sending -1 -3 -0.5... <10:38:23> posgen> (4, -2, -2.5)
    25. <10:38:09> sending -3 1 -0.5... <10:38:23> posgen> (-1, -3, -0.5)
    26. <10:38:09> sending -3 -3 -2.5... <10:38:23> posgen> (-3, 1, -0.5)
    27. <10:38:09> sending -4 -4 -0.5... <10:38:23> posgen> (-3, -3, -2.5)
    28. <10:38:09> sending 0 4 -1.5... <10:38:23> posgen> (-4, -4, -0.5)
    29. <10:38:09> sending 3 -4 -0.5... <10:38:23> posgen> (0, 4, -1.5)
    30. <10:38:09> sending 3 1 -1.5... <10:38:23> posgen> (3, -4, -0.5)
    31. <10:38:09> sending 4 4 -0.5... <10:38:23> posgen> (3, 1, -1.5)
    32. <10:38:09> sending 1 1 -2.5... <10:38:23> posgen> (4, 4, -0.5)
    33. <10:38:09> sending 3 -1 -2.5... <10:38:23> posgen> (1, 1, -2.5)
    34. <10:38:09> sending -2 2 0.5... <10:38:23> posgen> (3, -1, -2.5)
    35. <10:38:09> stop <10:38:23> posgen> (-2, 2, 0.5)
    36. <10:38:22> start <10:38:23> posgen> (-2, -4, -1.5)
    37. <10:38:22> sending -2 -4 -1.5... <10:38:23> posgen> (-3, 0, -0.5)
    38. <10:38:22> sending -3 0 -0.5... <10:38:23> posgen> (1, -3, -1.5)
    39. <10:38:23> sending 1 -3 -1.5... <10:38:23> posgen> (1, -4, -1.5)
    40. <10:38:23> sending 1 -4 -1.5... <10:38:23> posgen> (0, 2, 1.5)
    41. <10:38:23> sending 0 2 1.5... <10:38:23> posgen> (3, 0, -1.5)
    42. <10:38:23> sending 3 0 -1.5... <10:38:23> posgen> (-1, 4, 0.5)
    43. <10:38:23> sending -1 4 0.5... <10:38:23> posgen> (-1, -2, -0.5)
    44. <10:38:23> sending -1 -2 -0.5... <10:38:23> posgen> (0, -2, 0.5)
    45. <10:38:23> sending 0 -2 0.5... <10:38:23> posgen> (-2, -3, -0.5)
    46. <10:38:23> sending -2 -3 -0.5... <10:38:23> posgen> (-5, 1, 0.5)
    47. <10:38:23> sending -5 1 0.5... <10:38:23> posgen> (-5, -4, -1.5)
    48. <10:38:23> sending -5 -4 -1.5... <10:38:23> posgen> (4, 0, 0.5)
    49. <10:38:23> sending 4 0 0.5... <10:38:23> posgen> (1, -2, -1.5)
    50. <10:38:23> sending 1 -2 -1.5... <10:38:23> stopping sim...
    51. <10:38:23> sending 0 -2 1.5... <10:38:23> posgen> (0, -2, 1.5)
    52. <10:38:23> sending -5 -2 -1.5... <10:38:23> posgen> (-5, -2, -1.5)
    53. <10:38:23> sending 2 4 -2.5... <10:38:23> posgen> (2, 4, -2.5)
    54. <10:38:23> sending -2 0 -0.5... <10:38:23> posgen> (-2, 0, -0.5)
    55. <10:38:23> sending 4 -4 -0.5...
    56. <10:38:23> sending 1 -4 -0.5...
    57. <10:38:23> sending -5 -4 -2.5...
    58. <10:38:23> sending -3 -3 1.5...
    59. <10:38:23> sending -5 0 -1.5...
    60. <10:38:23> sending 3 -2 -1.5...
    61. <10:38:23> sending 3 3 -1.5...
    62. <10:38:23> sending -4 1 -1.5...
    63. <10:38:23> sending 2 -5 1.5...
    64. <10:38:23> sending 4 3 1.5...
    65. <10:38:23> sending -1 4 0.5...
    66. <10:38:23> sending 2 0 -1.5...
    67. <10:38:23> sending -1 3 -1.5...
    68. <10:38:23> sending 3 2 0.5...
    69. <10:38:23> sending -5 4 -2.5...
    70. <10:38:23> sending 1 4 -2.5...
    71. <10:38:23> sending -5 -4 0.5...
    72. <10:38:23> sending 0 0 0.5...
    73. <10:38:23> sending -5 -4 -0.5...
    74. <10:38:23> sending 2 -1 -1.5...
    75. <10:38:23> sending 2 -5 -0.5...
    76. <10:38:23> sending -1 -4 -0.5...
    77. <10:38:23> sending -4 3 0.5...
    78. <10:38:23> sending 0 2 -1.5...
    79. <10:38:23> sending -1 2 -1.5...
    80. <10:38:23> sending 3 -3 0.5...
    81. <10:38:23> sending -5 -3 -0.5...
    82. <10:38:23> sending 3 3 -2.5...
    83. <10:38:23> sending 4 2 -1.5...
    84. <10:38:23> sending -2 -1 -0.5...
    85. <10:38:23> sending -4 -2 -0.5...
    86. <10:38:23> sending -4 -3 -0.5...
    87. <10:38:23> stop
    To copy to clipboard, switch view to plain text mode 
    Last edited by criss; 19th July 2006 at 09:03. Reason: bug fix

  9. #9
    Join Date
    Feb 2006
    Posts
    26
    Thanked 2 Times in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: qt network performance

    Hi,

    I didn't had enough time to check how TCP sockets are configured by default in qt, but TCP socket can use by default an optimization (its name is nagle algorithm) in order to avoid sending too much little packets and for automatically merging them. A sample :

    - you send 100 packets of 3 bytes each second. As a TCP header is around 5x32 bits ( = 20 bytes), and an IP header is around 5x32 bits ( = 20 bytes) you will send 100 * (20 + 20 + 3) bytes per second = 4300 bytes / second.

    The optimization of the TCP layer is to wait a little bit before sending a packet, if in the next few milliseconds another bloc of data has to be sent, it will merge the two blocs of data into only one and send them in only one packet.
    In the sample above, imagine all the 100 packets are merged in only one packet, you will have to send (20+20) + 3*100 = 340 bytes / second.

    The problem with this optimization is that for sepcific cases (like yours) you rather prefer to increase the bandwith needed in order to lower the transmission delay.
    A flag exists in order to switch of this optimization. It is called TCP_NO_DELAY.

    As far as I know, you cannot choose to enable or disable this flag in Qt directly. To my mind (and if it's really because of that), you will have to write platform dependent code and call OS specific functions to set the flag.

    For example, here is an example on how to disable TCP_NO_DELAY on unix platforms :
    Qt Code:
    1. /* Disable the Nagle (TCP No Delay) algorithm ON UNIX PLATFORMS */
    2. int sockID, flag, ret;
    3. sockID = yourQTcpSocket->socketDescriptor();
    4. flag = 1;
    5. ret = setsockopt( sockID, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) );
    6.  
    7. if (ret == -1) {
    8. // error while trying to disable the nagle optimization
    9. }
    To copy to clipboard, switch view to plain text mode 

    For windows platforms, according to this article on msdn, it seems to be :

    Qt Code:
    1. /* Disable the Nagle (TCP No Delay) algorithm ON WINDOWS PLATFORMS */
    2. SOCKET sockId = yourQTcpSocket->socketDescriptor();
    3. int ret;
    4. BOOL bOptVal = true; // seems to be true here, but not completely sure.
    5. ret = setsockopt(sockID, IPPROTO_TCP, TCP_NODELAY, (char*)&bOptVal, sizeof(bool))
    6.  
    7. if ( ret == SOCKET_ERROR) {
    8. // error while trying to disable the nagle optimization
    9. int error = WSAGetLastError(void);
    10. }
    To copy to clipboard, switch view to plain text mode 

    My 2 cents.
    Last edited by nouknouk; 19th July 2006 at 11:16.

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

    Default Re: qt network performance

    Quote Originally Posted by nouknouk
    I didn't had enough time to check how TCP sockets are configured by default in qt, but TCP socket can use by default an optimization (its name is nagle algorithm) in order to avoid sending too much little packets and for automatically merging them.

    (...)

    The optimization of the TCP layer is to wait a little bit before sending a packet, if in the next few milliseconds another bloc of data has to be sent, it will merge the two blocs of data into only one and send them in only one packet.
    In the sample above, imagine all the 100 packets are merged in only one packet, you will have to send (20+20) + 3*100 = 340 bytes / second.

    The problem with this optimization is that for sepcific cases (like yours) you rather prefer to increase the bandwith needed in order to lower the transmission delay.
    A flag exists in order to switch of this optimization. It is called TCP_NO_DELAY.
    It's not that. Flushing the socket causes setting the PUSH flag on the TCP segment which makes the TCP implementation send the segment as soon as possible (when the congestion allows it) and not doing any delayed optimisations like segment merging. And even if the push flag wasn't set, the data would still be sent some miliseconds later, it can't be held in the queue for too long.

  11. #11
    Join Date
    Feb 2006
    Posts
    26
    Thanked 2 Times in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: qt network performance

    Quote Originally Posted by wysota
    Flushing the socket causes setting the PUSH flag on the TCP segment which makes the TCP implementation send the segment as soon as possible
    Could you please tell me where did you find those informations, I'm really interrested.

    Thanks.

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

    Default Re: qt network performance

    It's surely in RFC793 and follow-ups.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt network performance

    Quote Originally Posted by criss
    Qt Code:
    1. void connectionhandler::readdata()
    2. {
    3. ds >> inp;
    4.  
    5. if(inp.compare("modulename") == 0)
    6. {
    7. ds >> inp;
    8. emit modulename(inp, nr);
    9. }
    10. else if(inp.compare("posgen") == 0)
    11. {
    12. double x, y, z;
    13. ds >> x >> y >> z;
    14. emit forwardto("imggen", x, y, z);
    15. emit message(tr("posgen> (%1, %2, %3)").arg(QString("%1").arg(x), QString("%1").arg(y), QString("%1").arg(z)));
    16. }
    17. else if(!inp.isEmpty())
    18. emit message(tr("%1: %2").arg(QString("%1").arg(nr), QString("%1").arg(inp)));
    19. }
    To copy to clipboard, switch view to plain text mode 
    A small question: what happens when you receive more than one message? You always read only 3 values.

    In TCP you receive a stream of bytes and there is no distinction between messages/packets. It's your job to check if you have received a whole message, part of it, or even more than one message.

    http://www.qtcentre.org/forum/f-newb...v402-2191.html

  14. #14
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Re: qt network performance

    what i'm trying to realize is: first receiving a qstring (e.g. modulename, posgen, ...) to know, what kind of data will come and then accepting the data. for example, first is "posgen" received, then i know, that 3 double values will come.

    i know and read the posting you send... so you mean, in the way i'm trying to receive data, there will be "problems" while receiving. this means, i have to read everything to a buffer and then parsing the buffer to extract all of my needed data?? so the qdatastream is not enough? is this correct?

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt network performance

    Quote Originally Posted by criss
    i know and read the posting you send... so you mean, in the way i'm trying to receive data, there will be "problems" while receiving. this means, i have to read everything to a buffer and then parsing the buffer to extract all of my needed data?? so the qdatastream is not enough? is this correct?
    Not necessarily, just readyRead() signal means that there are new data available, but it doesn't say how much data. You might receive only a part of a message or more than one message. If you won't read all available data (except for the incomplete message), they will stay in the buffer forever and it will look like client was receiving less data than server sends.

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

    Default Re: qt network performance

    It could be easier for you if you separate each message with a new line character and use a textstream instead of datastream. Then you can check if there are more lines to read and read line by line. Of course you can try to do simmilar things using QDataStream::atEnd(), but you'll probably have to use it quite often (before every read).

  17. The following user says thank you to wysota for this useful post:

    criss (24th July 2006)

  18. #17
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: qt network performance

    now i had time to finish that part and it worked. thanks again.

Similar Threads

  1. more network connections simultaneously
    By cmeliak in forum Qt Programming
    Replies: 9
    Last Post: 8th June 2006, 00:17
  2. Qt4: QDir::entryList bug in windows when listing network files?
    By Yvon Halbwachs in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 14:22
  3. [QT 4] QTextEdit performance
    By fellobo in forum Qt Programming
    Replies: 8
    Last Post: 6th March 2006, 19:27
  4. Increasing performance from Qtextedit, listview, etc?
    By taylor34 in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2006, 10:20

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.