Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.6, JRuby 1.6.7
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Code: https://github.com/jordansissel/experiments/blob/master/ruby/sockets/listen.rb
% ruby listen.rb NoMethodError: undefined method `accept' for #<Socket:0x52c4c57> (root) at listen.rb:12 % ruby --1.9 listen.rb NoMethodError: undefined method `accept' for #<Socket:fd 6> (root) at listen.rb:12
Here's a breakdown of looking for Socket#accept on various rubies:
{:version=>"1.8.7 @ jruby-1.6.5", :has_accept?=>false}
{:version=>"1.8.7 @ jruby-1.6.6", :has_accept?=>false}
{:version=>"1.8.7 @ jruby-1.6.7", :has_accept?=>false}
{:version=>"1.8.7 @ ruby", :has_accept?=>true}
{:version=>"1.9.2 @ jruby-1.6.5", :has_accept?=>false}
{:version=>"1.9.2 @ jruby-1.6.6", :has_accept?=>false}
{:version=>"1.9.2 @ jruby-1.6.7", :has_accept?=>false}
{:version=>"1.9.2 @ ruby", :has_accept?=>true}
{:version=>"1.9.3 @ ruby", :has_accept?=>true}
Thoughts?
The reason we have never implemented this is because the JDK separates server from client sockets at construct time. We can't open a socket first and then decide it will act as a server later. We must make that decision when we construct the object that actually opens up an fd.
The question for me has always been this: why can't a user decide that it's a ServerSocket when they're opening it?
I'll poke around and see if anything has changed in the JDK APIs we use, but that's the short story.