From: Jean-Francois Nadeau Date: 2004-07-06T21:50:40+09:00 Subject: Windows - Socket - Connect - Nonblocking Hi, Ruby1.8.1, native ruby (from the pragmatic guys), WinXP. I am building a very nice Windows RSS aggregator which some of it is written in Ruby. I really like Ruby because it makes me very productive. Nice work. In my software, I need to pull the various RSS feeds as fast as I can. Therefore, I create a thread pool to minimize the network latency of each feed. It seemed at first that the IO was not multi-thread enabled because the ruby process unexpectedly became idle sometimes and after a few seconds, it started back running. I decided to investigate the problem by looking at the ruby source code. I saw that because the thread scheduler works with "select()", there should not be any blocking in multi-threaded socket IO. I put some traces in the ruby C code and discovered that the socket connect call is not nonblocking in Windows. Here is a ruby snippet to try it: require 'net/http' t= Thread.new do while 1 puts "in thread" end end h = Net::HTTP.new('192.168.0.80', 80) t.join Replace 192.168.0.80 with your bogus IP and you will see that "in thread" messages do not appear while ruby enters Net::HTTP.new. 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. Regards, Jean-Francois Nadeau http://www.jfnadeau.com