• 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
select is not working for me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

select is not working for me


  • Subject: select is not working for me
  • From: Tomas Zahradnicky <email@hidden>
  • Date: Sun, 19 Oct 2003 21:05:52 +0200

Hello,

I'm writing udp broadcasting code and I'd like to use select to gather replies to not eat processor time. Here's what I do:

1) I open udp socket
2) I set SO_BROADCAST options
3) I bind udp socket to wildcard INADDR_ANY address
4) I use sendto with INADDR_BROADCAST
5) Then I'd like to use select to suspend process until I get data:

for(;;)
{
FD_ZERO(&rdset);
FD_SET(cookie->fSocket, &rdset);

tv.tv_sec = 2;
tv.tv_usec = 0;

err = select(1, &rdset, NULL, NULL, &tv);

if( err == 1 )
{
// got data

err = recvfrom( cookie->fSocket, &dg,
sizeof(DatagramRec), 0,
(struct sockaddr *)&sa, &salen );

if( err == sizeof(DatagramRec) )
{
ProcessDatagramReply( cookie, &dg );
err = 0;
}
}
else if( !err )
{
// select timed out
break;
}
}

but the select times out. If I step directly to recvfrom, I get the data OK. What might be wrong?


Thanks,

Tomas
--
Ing. Tomas Zahradnicky, Jr.
Production Manager, 24U Software
Associate Member, Filemaker Solutions Alliance
mailto:email@hidden
http://www.24uSoftware.com
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: select is not working for me
      • From: Ian Lister <email@hidden>
  • Prev by Date: Re: Setting System Preferences Programatically
  • Next by Date: Re: select is not working for me
  • Previous by thread: Re: Setting System Preferences Programatically
  • Next by thread: Re: select is not working for me
  • Index(es):
    • Date
    • Thread