Backport #1753

non success open client socket not detected on windows

Added by raubarede (regis d'aubarede) almost 3 years ago. Updated about 1 year ago.

[ruby-core:24234]
Status:Assigned Start date:07/09/2009
Priority:Normal Due date:
Assignee:wyhaines (Kirk Haines) % Done:

0%

Category:-
Target version:-

Description

Here the code and execution with different ruby version :


D:\usr\ruby\local\dsd17>type z_essai.rb
require 'socket'

p "*************************************************"
p [RUBY_PLATFORM,RUBY_VERSION,RUBY_RELEASE_DATE]
p "*************************************************"
p "Before openning client socket on non existant server"
begin
  TCPSocket.open("localhost",4444) { |io| p [io,io.closed?]  }
  p "after openning client socket on non existant server"
rescue
  p "good, non connection is detected"
  p $!
end
p "*************************************************"


D:\usr\ruby\local\dsd17>ruby z_essai.rb
"*************************************************"
["i386-mswin32", "1.8.6", "2007-03-13"]
"*************************************************"
"Before openning client socket on non existant server"
"good, non connection is detected"
#<Errno::EBADF: Bad file descriptor - connect(2)>
"*************************************************"

D:\usr\ruby\local\dsd17>jruby z_essai.rb
"*************************************************"
["java", "1.8.6", "2009-06-15"]
"*************************************************"
"Before openning client socket on non existant server"
"good, non connection is detected"
#<Errno::ECONNREFUSED: Connection refused - Connection refused>
"*************************************************"


D:\usr\ruby\local\dsd17>ruby19 z_essai.rb
"*************************************************"
["i386-mswin32", "1.9.1", "2009-01-30"]
"*************************************************"
"Before openning client socket on non existant server"
[#<TCPSocket:0xabf914>, false]
"after openning client socket on non existant server"
"*************************************************"

D:\usr\ruby\local\dsd17>

History

Updated by rogerdpack (Roger Pack) almost 3 years ago

I get this too [for mingw 1.9].  Odd.
=r

Updated by phasis68 (Heesob Park) almost 3 years ago

This patch will fix the problem.

--- win32.c     2009-01-16 00:37:20.000000000 +0900
+++ win32.c.new 2009-07-10 23:34:06.000000000 +0900
@@ -2397,6 +2397,7 @@
            r = WSAGetLastError();
            if (r != WSAEWOULDBLOCK) {
                errno = map_errno(r);
+               r = -1;
            }
            else {
                errno = EINPROGRESS;

Updated by phasis68 (Heesob Park) almost 3 years ago

This is the bug of ruby 1.9.x not 1.8.7.
Is there any reason not applying this patch?

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to wyhaines (Kirk Haines)
I heard that this bug has been fixed for trunk and ruby_1_8.  I've also backported that fix to 1.8.7.
Sorry for not checking other branches e.g, 1.8.6.  Assigning to Kirk Haines for the moment.

Also available in: Atom PDF