From: Jean-Francois Nadeau Date: 2004-07-07T00:00:14+09:00 Subject: Re: Windows - Socket - Connect - Nonblocking > >So, I was wondering if this was a known problem. I have modified the ruby > >code to fix that problem but I don't know if my patch is 100% safe. Where > >should I send my patch and how? > > > >My patch definitely improves the performance of my code. > > try here or on the ruby-core mailing list. > > OTOH, ou may just try your patched interpreter against the standard > test suite, as a first try. I ran nmake test and it is successful. However, in dir "test", I don't see a socket unit test. I will clean my code and send a patch shortly. One thing that would help me is to know the location in the ruby source code where a socket is put in nonblocking mode. I did not see it in the socket creation part... In ruby_connect (socket.c I think), fcntl is called to make it non-blocking but that does not compile in Win32. (fcntl does not exist.) My quick patch is to put the Win32 socket in non-blocking mode with ioctlsocket() after the ::socket call. Then, I have to trap WSAEWOULDBLOCK in Win32 connect (win32.c) and return instead EINPROGRESS. Then everything seems to work very well. (ruby_connect gives the FD to the thread scheduler...) Does a socket is in non-blocking mode by default in Ruby? Jean-Francois Nadeau http://www.jfnadeau.com