I have a application running on a Windows XP platform (i7 2.1 Ghz processor). This application is a master/slave based communication between master and slave nodes, over UDP. The master sends a request and slave node sends in its response (Burst Mode), packets of data every 5 ms, each data packet 1300 Byte long including header.
Back in the master node the main thread receives the data and writes it to a queue, triggering a parallel thread to read out from the thread.
Problem: The execution time for the Winsock API is very long while reading the next packet, and so the data is being lost from the buffer.
Execution time: Recvfrom() - 200 - 400 Microseconds.
Open_Sock ()
{
socket();
//Error check
connect ();
//Error Check
}
Receivethread()
{
sock again:
select(socket, read,write,excep,(0,0));
//error check
rc = recvfrom(socket,buf,len,0,&s_addr,&cln_alen)
if(rc>0) {
enqueue(queue,buf);
}
}
I am sure the Winsock API does not require such a long time just to fetch the next packet. But I cannot find any information on what the real execution times should be. Any help in the direction is really appreciated.
recvfrom()will wait for data to arrive before exiting. Since you are usingselect(), is the socket actually in a readable state before you callrecvfrom()? Knowing that the socket is in blocking mode, you could also just get rid ofselect(), unless your thread needs to do other threads while waiting for data. - Remy Lebeau