Results 1 to 6 of 6

Thread: QT Network Performance.

  1. #1
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QT Network Performance.

    Hi,
    I am developing a realtime application.
    I have a server that is written in C and this pumps data to the server at the maximum possible rate.
    i tried using Qt sockets to receive the data from the server. i used readyread signal to read the data from the socket and display. The code is given below.

    i find some data loss out of the 1000 messge sent from server to the client, i receive only 967.
    but the same when i receive it with C sockets i am able to receive all the 1000 data from the server. can anyone tell where the problem is?
    if not please tell the way to improve the performance. i tried using Qt::AutoConnection also but the result was the same.


    Qt Code:
    1. QObject::connect(m_tcpsocket,SIGNAL(readyRead()),this,SLOT(readmsg()),Qt::DirectConnection);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void QClass1::readmsg()
    2. {
    3. m_count++;
    4. printf("\nCOUNT: %d",m_count);
    5. S_Msg m_header;// this is a structure
    6. void *ptr=&m_header;
    7. m_tcpsocket->read((char *)ptr,MSG_SIZE);
    8. printf("\n\nRecieved ID ");
    9. printf("%x",m_header.id);
    10.  
    11. switch(m_header.id)
    12. {
    13. case 1:
    14. {
    15. S_LOT plt; //object for struct S_LOT
    16. void *vptr_msg=&plt.th;
    17. m_tcpsocket->read((char *)vptr_msg,LOT_SIZE-MSG_SIZE);
    18. emit Signal1(plt);
    19. break;
    20. }
    21. .
    22. .
    23. .
    24. .
    25. default:
    26. //
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 
    Count output with Qt Sockets for 1000msgs sent from the server was 978
    Count output with C Sockets for 1000msgs sent from the server was 1000


    --
    pls help

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT Network Performance.

    What was the number of times you recorded the comparison ??
    Are u getting loss with Qt Socket all the time ??? or could it be prob of the network ??

    Also whats the code with C Socket ??

  3. #3
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QT Network Performance.

    Qt Code:
    1. send(sockfd,&message,sizeof(message),0);
    2. for(;;)
    3. {
    4. recv(sockfd, &array, 8, 0);
    5. if(array[3] == 0x3005)
    6. {
    7. //printf("PLOT from server=%4x\n", array[3]);
    8. printf("Message %d.\n",++count);
    9. recv(sockfd, &array, 24, 0);
    10. }
    11. else if(array[3] == 0x3004)
    12. {
    13. //printf("CAP from server=%4x\n", array[3]);
    14. recv(sockfd, &array, 2, 0);
    15. printf("Message %d.\n",++count);
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 
    i have tried that for atleast ten different sets.
    the result is the same
    Last edited by wysota; 3rd April 2008 at 18:18.

  4. #4
    Join Date
    Jan 2006
    Location
    Boston, MA
    Posts
    40
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT Network Performance.

    Did you check total size of received data ? Because some "tcp messages" may bound together, but not lost.

  5. #5
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QT Network Performance.

    Did you check total size of received data ? Because some "tcp messages" may bound together, but not lost.
    what should i do to avoid that....!
    Last edited by wysota; 3rd April 2008 at 20:54.

  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.

    The fact that readyRead() was emitted less than 1000 times doesn't mean there are less than 1000 messages in the buffer. Instead of reading one message at a time, read as many messages at once as there are waiting in the buffer.

    Qt Code:
    1. while(sock->bytesAvailable()>=8){
    2. QByteArray dat = sock->read(8);
    3. doSomething(dat);
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Checking network availability
    By fullmetalcoder in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2008, 20:23
  2. No network when Modem Emulator connect to a real device
    By tommy_tang in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 10th December 2007, 09:24
  3. QByteArray with network data
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2007, 18:53
  4. QSocket - signal for network wire disconnection
    By manivannan_1984 in forum Qt Programming
    Replies: 7
    Last Post: 5th September 2006, 14:52

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.