跨平台socket select 的bug

这个bug搞了我两天, 大致就是说select 函数在linux 下 每次调用都会重置timeout参数值, 
所以需要在每次调用select 函数之前, 重新设置timeout (window下面不会重置timeout)。
---------------------------------------------------------------------------------------------

On Linux, select() modifies timeout to reflect the amount of time not
slept; most other implementations do not do this. (POSIX.1-2001 per-
mits either behaviour.) This causes problems both when Linux code
which reads timeout is ported to other operating systems, and when code
is ported to Linux that reuses a struct timeval for multiple select()s
in a loop without reinitializing it. Consider timeout to be undefined
after select() returns.
 ---------------------------------------------------------------------------------------------
posted @ 2010-04-01 23:45  史莱姆  阅读(469)  评论(0编辑  收藏  举报