Results 1 to 3 of 3

Thread: Question in readyRead(QTCPSOCKET)

  1. #1
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Question in readyRead(QTCPSOCKET)

    Hello.

    I got trouble in socket programming.

    My server is send packet 350-360 times.
    But, client does not emit readReady SIGNAL 350-360.
    I got readReady SIGNAL just 3-5 time.
    Is it Bug? or What i missed?

    server is like it.
    Qt Code:
    1. while((sql_row=mysql_fetch_row(sql_result))!=NULL)
    2. {
    3. user_information_init(&user_info);
    4. if(sql_row[0]!=NULL)
    5. strcpy(user_info.id, sql_row[0]);
    6. if(sql_row[1]!=NULL)
    7. strcpy(user_info.name, sql_row[1]);
    8. if(sql_row[2]!=NULL)
    9. strcpy(user_info.grade, sql_row[2]);
    10. if(sql_row[3]!=NULL)
    11. strcpy(user_info.phone, sql_row[3]);
    12. if(sql_row[4]!=NULL)
    13. strcpy(user_info.email, sql_row[4]);
    14. if(sql_row[5]!=NULL)
    15. strcpy(user_info.homepage, sql_row[5]);
    16. code = 1000;
    17. memset(&buf, 0x00, MAXBUF_SIZE);
    18. memcpy(&buf[0], &code, sizeof(code));
    19. memcpy(&buf[4], &size, sizeof(size));
    20. memcpy(&buf[8], &user_info, sizeof(user_info));
    21. send(cfd, buf, 8+size, 0);
    22. }
    To copy to clipboard, switch view to plain text mode 

    client is like it.
    Qt Code:
    1. connect(this, SIGNAL(readyRead()), this, SLOT(receive_slot()));
    2. receive_slot()
    3. {
    4. qDebug("Buddy_Info");
    5. //server send packet 350-360 time
    6. // but i got a 3-5 output message.
    7. //Is it Bug? or What i missed?
    8. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2008
    Posts
    47
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question in readyRead(QTCPSOCKET)

    Did you check if the packages have arrived in a chunk?

    When during the readyRead() signal a new package arrive, there is now new readyRead() signal emitted.

    You need to check with bytesAvailable() how many bytes are there and then split the bytes by your self again into single packages.

  3. The following user says thank you to muellerp for this useful post:

    morgana (24th July 2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question in readyRead(QTCPSOCKET)

    To. muellerp

    Thank you.(_ _)

Similar Threads

  1. SQL Question
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2008, 19:36
  2. Exceptions / setjmp/longjmp question
    By Aceman2000 in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2008, 17:14
  3. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 17:49
  4. Replies: 1
    Last Post: 15th March 2007, 20:45

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.