• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Can not receive packages from opened socket
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can not receive packages from opened socket


  • Subject: Can not receive packages from opened socket
  • From: Robin <email@hidden>
  • Date: Tue, 31 Oct 2006 13:01:56 +0800

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Can not receive packages from opened socket
      • From: Josh Graessley <email@hidden>
  • Prev by Date: Re: detecting whether a port is in use
  • Next by Date: Re: Can not receive packages from opened socket
  • Previous by thread: Re: detecting whether a port is in use
  • Next by thread: Re: Can not receive packages from opened socket
  • Index(es):
    • Date
    • Thread