select on udp recvfrom doesn't work ???

Dave Cramer davec-zxk95TxsVYDyHADnj0MGvQC/G2K4zDHf at public.gmane.org
Mon Aug 16 20:01:55 UTC 2010


Hi Lennart,

Did this work on your machine, I tried it on a few and it didn't do
anything when I sent the message via nc

Dave

On Wed, Aug 11, 2010 at 2:34 PM, Lennart Sorensen
<lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org> wrote:
> On Wed, Aug 11, 2010 at 01:22:08PM -0400, Dave Cramer wrote:
>> Len,
>>
>> > How about this little example.  It waits for a UDP message (anything at
>> > all) on port 5000, and when that happens it starts to print a message
>> > every 10 ticks, with a tick rate of 10ms, (so 10 times per second it
>> > does the print).
>> >
>> > I start it by doing:
>> >
>> > echo "Foo" | nc -u ipaddress 5000 -q 1
>> >
>> > nc is netcat.  Any other udp capable network connection should work too.
>> >
>>
>> Thanks for taking the time to write this, couple questions:
>>
>> 1) sock = socket(AF_INET, SOCK_DGRAM, 0); this seems to be a common
>> mistake. it should be socket(BF_INET....) happens that AF_INET and
>> BF_INET both = 2
>>
>> Where does it do the read ? or does it block on the bind ?
>
> Sorry it should be PF_INET, not AF_INET (nor BF_INET).
>
> The read is recvfrom after the select.
>
> It doesn't care what the message is, just that it receives one as a
> start trigger.
>
> --
> Len Sorensen
> --
> The Toronto Linux Users Group.      Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>
>
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list