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.
Code:
while((sql_row=mysql_fetch_row(sql_result))!=NULL)
{
user_information_init(&user_info);
if(sql_row[0]!=NULL)
strcpy(user_info.id, sql_row[0]);
if(sql_row[1]!=NULL)
strcpy(user_info.name, sql_row[1]);
if(sql_row[2]!=NULL)
strcpy(user_info.grade, sql_row[2]);
if(sql_row[3]!=NULL)
strcpy(user_info.phone, sql_row[3]);
if(sql_row[4]!=NULL)
strcpy(user_info.email, sql_row[4]);
if(sql_row[5]!=NULL)
strcpy(user_info.homepage, sql_row[5]);
code = 1000;
memset(&buf, 0x00, MAXBUF_SIZE);
memcpy(&buf[0], &code, sizeof(code));
memcpy(&buf[4], &size, sizeof(size));
memcpy(&buf[8], &user_info, sizeof(user_info));
send(cfd, buf, 8+size, 0);
}
client is like it.
Code:
connect(this, SIGNAL(readyRead()), this, SLOT(receive_slot()));
receive_slot()
{
qDebug("Buddy_Info");
//server send packet 350-360 time
// but i got a 3-5 output message.
//Is it Bug? or What i missed?
}
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.
Re: Question in readyRead(QTCPSOCKET)
To. muellerp
Thank you.(_ _) :)