Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can not receive packages from opened socket



Hi, All

I did my receive package as this, 1. open socket  2. bind . 3 receive package. But I can not get any packets from the opened socket by Airport Extreme card. The AP has sent many BROADCAST packets at the same time, I've caught them on the PC system. On the other side, I can send package successfully by this way. I't s very strange. 

This is my action, 

1. open socket // successfully
fd_recv = socket(AF_NDRV, SOCK_RAW, 0x0);//decided by the hardware

2. bind  // successfully
strcpy(gEnetDataPtr->saddr.sa_data, gedata[gCurrEnetEntry].bsdName);
gEnetDataPtr->saddr.sa_len = sizeof(struct sockaddr);
gEnetDataPtr->saddr.sa_family = AF_NDRV;
err = bind(gEnetDataPtr->fd_recv, &(gEnetDataPtr->saddr), sizeof(gEnetDataPtr->saddr));

3. receive data  // always get 0 bytes
int nFlag = MSG_TRUNC|= MSG_DONTWAIT;

fd_set set;
struct timeval tout;

addrlen = sizeof(m_bEtherNetData->saddr);
memset(&m_bEtherNetData->saddr,0, addrlen);
tout.tv_sec =0;
tout.tv_usec = 500000; //decided by the hardware


FD_ZERO(&set);
FD_SET(m_bEtherNetData->fd_recv, &set);
if(select(m_bEtherNetData->fd_recv + 1 , &set, NULL, NULL, &tout)> 0 && FD_ISSET(m_bEtherNetData->fd_recv, &set))
{
nRead = recvfrom(m_bEtherNetData->fd_recv, pRxPackage->PacketBuffer, pRxPackage->PacketBufferLength, nFlag , &(m_bEtherNetData->saddr), &addrlen);
fprintf (stderr, "receive package OK,  get %d byetes ... \n", nRead);
}else
{
nRead = -1;
fprintf (stderr, "receive package error ...\n");
}


I do not know what wrong it is, and I run the BSDLLC example, it can not get any packet too.

Does anyone know what else should I do ? Any suggestion is grateful!

Best regards,
Robin
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.