Simon Josefsson wrote: > Paolo Bonzini <[EMAIL PROTECTED]> writes: > >> This revised patch includes the select(2) wrapper in sys_select, >> not sys_socket. This makes sense given the very purpose of the >> wrapper -- which is to let the client use select for other descriptor >> types than socket handles. > > Btw, if you didn't like your code here, what do you think of the code > I've been using in GnuTLS so far? See: > > http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=blob;f=src/select.c;hb=HEAD
The main difference is that your code assumes file descriptors and socket handles do not overlap; mine instead assumes that winsock.c is in use (and hence that there are no separate socket handles). Your code is much less ugly, and has a couple of optimizations in the case all the file descriptors are sockets. The downside of your implementation is that it does not handle console handles (e.g. stdin) and does not detect writeability of pipes. Also, it has an almost-busy-waiting loop that my code does not have. In particular, while your code alternates checking pipes and sockets every 0.1 sec., mine polls at the beginning and asks Winsock to set an event when a socket becomes ready (because you can wait on pipes and events, but not on pipes and sockets). > Personally I'd be happy to replace the hack I've been using with your > implementation, but if there is anything to keep in mind before doing > that, it would be useful to know. No, except that any hack to use closesocket/WSAGetLastError instead of close/errno *must* be removed. As soon as my thing goes in, you should be able to replace your select.c and the aforementioned hacks with the gnulib modules errno, sys_socket and sys_select. Paolo