Hi, all I found my application sometimes get 0 bytes when I use recvfrom() to get raw ethernet packet from the Wireless network. I'm sure the target always send fixed bytes packets, I can use sniffer to catch the packet on the PC system. it has no rules to get 0 bytes or fixed length bytes ( correct data), I do not know what happened. What else need I do?
My receive data functions as this,
int _Receive_Data(UInt8 * buffer, UInt16 len) { int nRead =0; unsigned int addrlen; int nFlag = MSG_TRUNC;
if(((SESSION_INFO_STRUCT *)m_bEtherNetData->m_pSessionAudio)->options & CA_NONBLOCKING) { nFlag |= MSG_DONTWAIT; }
addrlen = sizeof(m_bEtherNetData->saddr); memset(&m_bEtherNetData->saddr,0, addrlen);
nRead = recvfrom(m_bEtherNetData->fd_recv, buffer, len, nFlag , &(m_bEtherNetData->saddr), &addrlen);
fprintf (stderr, "receive package OK, get %d byetes ... \n", nRead); return nRead;
}
Any one has any ideas about it?
Thanks a lot!
Best regards, Robin |