1 /*=============================================================================
4 Copyright © 2008 Bruno Santos <nayart3@gmail.com>
5 =============================================================================*/
7 #include <sys/select.h>
12 ///////////////////////////////////////////////////////////////////////////////
13 void FD_ZERO(fd_set
* fs
)
15 memset(fs
, 0, sizeof(fd_set
));
18 void FD_SET(int fildes
, fd_set
* fs
)
20 HANDLE hd
= tcrt::fildes_to_handle(fildes
);
22 if (fs
->count
>= FD_SETSIZE
)
24 for (uint i
= 0; i
< fs
->count
; ++i
) {
25 if (fs
->fildes
[i
] == hd
)
28 fs
->fildes
[fs
->count
++] = hd
;
31 int FD_ISSET(int fildes
, fd_set
* fs
)
33 return Ws2_FDIsSet(tcrt::fildes_to_handle(fildes
), fs
);
36 int select(int nfds
, fd_set
* readfds
, fd_set
* writefds
, fd_set
* errorfds
, struct timeval
* timeout
)
41 DWORD msec
= timeout
->tv_sec
* 1000 + timeout
->tv_usec
/ 1000;
44 ret
= Ws2_Select(nfds
, readfds
, writefds
, errorfds
, timeout
);
46 errno
= Ws2_GetLastError();
52 // EOF ////////////////////////////////////////////////////////////////////////