AW: [En-Nut-Discussion] UdpReceiveFrom() blocking?

Oliver Schulz Oliver.Schulz at bong.de
Mon Nov 8 16:10:32 CET 2004


Hello Radek,

> It looks like the UdpReceiveFrom() function blocks even when I use it with
> timeout = 0. A fast look over the source revealed there's a call to
> NutEventWait() which switches threads regardless of the timeout value.
>Maybe I just got it all wrong... I know the timeout value is limited by
>the system timer granularity but 0 should be a special case. Just look if
Yes, using 0 for timeout value is a special case. It is interpreted as an infinite wait. 
See also definition on NUT_WAIT_INFINITE in include/sys/event.h.

So, if you want to have a kind of polling mechianism use the value of sock->so_rx_cnt. It contains the number of bytes in the udp receive buffer. If it's nonzero call NutUdpReceiveFrom().

Cheers,
Oliver.



More information about the En-Nut-Discussion mailing list