Hi, John
After I specify the types of packets with setsockopt(), I can get the data now. But there's a new question now, the recvfrom() sometimes read back 0 bytes, then it will keep on getting 0 bytes in the ring thread. When it return -1 one times, it will get the right length data packets then.
I filled the recvfrom() as this,
While(true) { int nFlag = MSG_TRUNC; int nRead =0; unsigned int addrlen; addrlen = sizeof(saddr); memset(&saddr,0, addrlen);
if(options & CA_NONBLOCKING) //NO_BLOCK MODE { nFlag |= MSG_DONTWAIT; }
nRead = recvfrom(>fd_recv, buffer, len, nFlag , &(saddr), &addrlen);
if(nRead > 0) { fprintf (stderr, "receive package OK, get %d byetes ... \n", nRead); } }
I guess there's still something wrong with the setting, for it's a random phenomenon that the application read 0 bytes and read real data.
Do you have any suggestion?
Thank you very much!
Best regards, Robin |