New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDPSocket Error inconsistent with MRI #3282

Closed
quoideneuf opened this Issue Aug 25, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@quoideneuf

quoideneuf commented Aug 25, 2015

When network is available:

> ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=40 time=67.330 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=40 time=67.808 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 67.330/67.569/67.808/0.239 ms

MRI:

> ruby -ve "require 'socket'; UDPSocket.open { |s| s.connect('8.8.8.8', 54); p s.addr }"
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
["AF_INET", 65170, "10.0.0.3", "10.0.0.3"]

JRuby:

> ruby -ve "require 'socket'; UDPSocket.open { |s| s.connect('8.8.8.8', 54); p s.addr }"
jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-20 d537cab Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b25 +jit [darwin-x86_64]
["AF_INET", 59035, "10.0.0.3", "10.0.0.3"]

When network is NOT available

> ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
Request timeout for icmp_seq 0
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss

MRI

> ruby -ve "require 'socket'; UDPSocket.open { |s| s.connect('8.8.8.8', 54); p s.addr }"
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
-e:1:in `connect': Network is unreachable - connect(2) for "8.8.8.8" port 54 (Errno::ENETUNREACH)
    from -e:1:in `block in <main>'
    from -e:1:in `open'
    from -e:1:in `<main>'

JRuby

> ruby -ve "require 'socket'; UDPSocket.open { |s| s.connect('8.8.8.8', 54); p s.addr }"
jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-20 d537cab Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b25 +jit [darwin-x86_64]
SocketError: connect: name or service not known
             connect at org/jruby/ext/socket/RubyUDPSocket.java:190
  -e_CLOSURE_1__-e_0 at -e:1
                open at org/j
@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Sep 3, 2015

Member

Interesting. JDK has an unfortunate lack of information on these catch-all exceptions. I'll see if we can produce a better error here.

Member

headius commented Sep 3, 2015

Interesting. JDK has an unfortunate lack of information on these catch-all exceptions. I'll see if we can produce a better error here.

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Sep 3, 2015

Member

Ok, looks like we're not using the catch-all exception reprocessing logic (Ruby.newIOErrorFromException) in UDPSocket, TCPSocket, or TCPServer. Fixing.

Member

headius commented Sep 3, 2015

Ok, looks like we're not using the catch-all exception reprocessing logic (Ruby.newIOErrorFromException) in UDPSocket, TCPSocket, or TCPServer. Fixing.

@headius headius closed this in 60be4d2 Sep 4, 2015

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Sep 4, 2015

Member

Not sure how to test this :-\

Member

headius commented Sep 4, 2015

Not sure how to test this :-\

@enebo enebo added this to the JRuby 9.0.2.0 milestone Oct 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment