Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

recvfrom() timeout

25 views
Skip to first unread message

John

unread,
Nov 13, 2009, 3:39:45 PM11/13/09
to
After using setsockopt() to set the receive timeout to XXX
milliseconds, the actual measured timeout is XXX + 530 milliseconds,
about. The XXX range used was 50 up to 1000 ms. This is true whether
I use TCP or UDP; copper Ethernet, WiFi or 127.0.0.1; test program
written in Delphi Pascal 6 or LCC c; or running on an XP or Win2000
machine. Comments?

Peter Duniho

unread,
Nov 13, 2009, 5:48:45 PM11/13/09
to

Even if you are measuring the timeout _as implemented by Winsock_
precisely (which is probably not the case), the fact is that AFAIK there
is no guarantee of specific precision for the timeout.

More likely, you are observing the time between some checkpoint (e.g.
receiving data, setting the timeout, etc.) and when the timeout actually
is noticed by your own code. And in that case, even if the timeout is
signaled to the nearest nanosecond by Winsock, there is no guarantee in
a non-real-time operating system like Windows that your own code will be
able to observe that signal in any specific time period.

There may be some real overhead in Winsock that is _also_ preventing an
exact timeout from being observed. But the fact is, a receive timeout
of even as long as 1 second is ridiculously short, a half second error
on the timeout should not be a problem at all for your code, and in all
likelihood you should really be implementing your own timeout logic in
your own code rather than using the receive timeout value in the socket
itself.

So, in other words...what you're describing sounds perfectly fine to me. :)

Pete

0 new messages