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.
QObject::connect(m_tcpsocket,
SIGNAL(readyRead
()),
this,
SLOT(readmsg
()),Qt
::DirectConnection);
QObject::connect(m_tcpsocket,SIGNAL(readyRead()),this,SLOT(readmsg()),Qt::DirectConnection);
To copy to clipboard, switch view to plain text mode
void QClass1::readmsg()
{
m_count++;
printf("\nCOUNT: %d",m_count);
S_Msg m_header;// this is a structure
void *ptr=&m_header;
m_tcpsocket->read((char *)ptr,MSG_SIZE);
printf("\n\nRecieved ID ");
printf("%x",m_header.id);
switch(m_header.id)
{
case 1:
{
S_LOT plt; //object for struct S_LOT
void *vptr_msg=&plt.th;
m_tcpsocket->read((char *)vptr_msg,LOT_SIZE-MSG_SIZE);
emit Signal1(plt);
break;
}
.
.
.
.
default:
//
}
}
void QClass1::readmsg()
{
m_count++;
printf("\nCOUNT: %d",m_count);
S_Msg m_header;// this is a structure
void *ptr=&m_header;
m_tcpsocket->read((char *)ptr,MSG_SIZE);
printf("\n\nRecieved ID ");
printf("%x",m_header.id);
switch(m_header.id)
{
case 1:
{
S_LOT plt; //object for struct S_LOT
void *vptr_msg=&plt.th;
m_tcpsocket->read((char *)vptr_msg,LOT_SIZE-MSG_SIZE);
emit Signal1(plt);
break;
}
.
.
.
.
default:
//
}
}
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
Bookmarks