recvfrom() could not return back with TimerTimeout

I am doing peer to peer wireless communication with two QNX6.3.2 machines using UDP. sending is okay, but on the recvfrom() thread, the program stuck just in the recvfrom() call, and the TimerTimeout(CLOCK_REALTIME,
_NTO_TIMEOUT_CONDVAR | _NTO_TIMEOUT_MUTEX | _NTO_TIMEOUT_RECEIVE, NULL, &nWait, NULL); could not timeout after 2ms of blocking in recvfrom(). even no data arrived, then the recvfrom() still should return after the timeout. i set the timeout value to 2ms.
Look for your help.

Eric

recvfrom is most probably in a REPLY state which you haven`t specified in the list.

i added _NTO_TIMEOUT_REPLY in the timertimeout set up, still got stuck in the recvfrom() :question: any other possible reasons?

Do a pidin while recvfrom is blocked, check the state it’s in.

Another possibility would be to use a UNIX style code where you call alarm(1) before the call to recvfrom(). If no packet is received within one second, the kernel will deliver a signal SIG_ALM and recvfrom() should return with EINTR. Although you cannot get anything smaller than 1 second it is worth a try.

Regards,
Albrecht

To get resolution better than 1 second use
ualarm ( useconds_t usec, useconds_t interval );

Regards,
Yuriy

Cool stuff. Wasn’t aware of the u-variant of that function. Is it POSIX?

-Albrecht

So it is.
Classification:
POSIX 1003.1 XSI
Regards,
Yuriy

thx, i got the point. the qnx doc: “Always call TimerTimeout() just before the function that you wish to timeout”. i just put one timertimeout before pthread_cond_wait, and forgot before the other–recvfrom().

Eric

As I knew that QNX recvfrom timeout (call setsocketopt() SO_RCVTIMEO of the recvfrom) is 50ms resolution.

But I did not know whether able to change? Can I use TimerTimeout() to get 10ms resolution instead of the 50ms resolution of recvfrom()?

If you need 10ms resolution maybe it’s worth looking at different option like a separate thread for reading or using a non blocking socket.