Bill Kelly wrote:

>From: "Matthew Margolis" <mrmargolis / wisc.edu>
>  
>
>>Bill Kelly wrote:
>>    
>>
>>>From: "Matthew Margolis" <mrmargolis / wisc.edu>
>>>
>>>      
>>>
>>>>I can not get a working TCPSocket under windows with ruby 1.8.2.  It 
>>>>just hangs.  Is there currently a solution for this problem?
>>>>   
>>>>        
>>>>
>>>Could you post your code?  I've used TCPSocket (and UDPSocket)
>>>heavily under Win32 ruby since, I think version 1.6.4... Currently
>>>running ruby 1.8.2 (2004-12-25) [i386-mswin32].
>>>
>>>      
>>>
>>sure
>>-----------------
>>require 'Timeout'
>>require 'socket'
>>time =5
>>
>>begin
>>  Timeout.timeout(time) do
>>    s = TCPSocket.new("google.com", "echo")
>>    puts "fish"
>>    s.close
>>  end
>> rescue Timeout::Error
>>      puts "Timed out"
>>end
>>----------------
>>I couldn't get ping.rb(stdlib) to work so I tried my own version and it 
>>doesn't work either.
>>    
>>
>
>Note, the above code also hangs under Linux, too. :)
>
>I think it's just that google.com doesn't answer 
>connection requests on port 7 (echo).
>
>Here's similar code (in irb on Windows) using http
>instead of echo:
>
>  
>
>>>require 'socket'
>>>      
>>>
>=> true
>  
>
>>>s = TCPSocket.new("google.com", "http")
>>>      
>>>
>=> #<TCPSocket:0x2dc1828>
>  
>
>>>s.print "GET / HTTP/1.0\r\n\r\n"
>>>      
>>>
>=> nil
>  
>
>>>s.gets
>>>      
>>>
>=> "HTTP/1.0 200 OK\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "Cache-Control: private\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "Content-Type: text/html\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "Set-Cookie: PREF=ID=5eb25ab2dffff310:TM=1109793965:LM=1109793965:
>S=MmppHbq23LjrmaeH; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/;
>domain=.google.com\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "Server: GWS/2.1\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "Date: Wed, 02 Mar 2005 20:06:05 GMT\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "Connection: Close\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "\r\n"
>  
>
>>>s.gets
>>>      
>>>
>=> "<html><head><meta http-equiv=\"content-type\" content=\"text/html;
>charset=ISO-8859-1\"><title>Google</title><style><!--\n"
>  
>
>>>s.close
>>>      
>>>
>=> nil
>
>
>HTH,
>
>Regards,
>
>Bill
>
>
>
>  
>
Thanks I will give that a try.

-Matt Margolis