Hi,

I was recently debugging a hang on the mysql2 gem. The cause turned
out to be that the socket file descriptor from libmysql was being
passed in to rb_thread_select():
https://github.com/brianmario/mysql2/blob/8c0c350c06c979c53b5eb67b95b9b313c8f297d8/ext/mysql2/client.c#L340

This worked fine on linux, but on Windows rb_thread_select would never
return. The rb_thread_select function expects CRT fds (made with
_open_osfhandle()). Ruby win32 code goes to great lengths to redefine
socket(), FD_SET, FD_ISSET, and a pile of other functions, so that
extensions like EventMachine create and work with the CRT fds instead
of the SOCKET handles transparently. However in cases like like mysql2
and curb (which uses libcurl), the socket is created by an external
library, and the handle is the SOCKET, not the CRT fd. Here's the curb
case: https://github.com/taf2/curb/blob/5f223a8f2e0de3e6c0b783296ce403613ef6b795/ext/curb_multi.c#L472

My question is; why does Ruby go through all this trouble on Windows?
Why not pass around and work with SOCKET handles instead?

-Greg