Skip to content
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

Socket.pair is not implemented #2984

Closed
ojab opened this issue May 25, 2015 · 4 comments
Closed

Socket.pair is not implemented #2984

ojab opened this issue May 25, 2015 · 4 comments

Comments

@ojab
Copy link

ojab commented May 25, 2015

require 'socket'
foo, bar = Socket.pair(:UNIX, :STREAM, 0)

leads to

NoMethodError: undefined method `pair' for Socket:Class
  method_missing at org/jruby/RubyBasicObject.java:1598
           <top> at /tmp/socket.rb:3

on jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-05-22 ac104e7 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]

@headius
Copy link
Member

headius commented May 26, 2015

We do have UnixSocket.pair...are there any other socket types for which Socket.pair works?

@headius
Copy link
Member

headius commented May 26, 2015

I think we can implement this simply enough for UNIX, but the other socket types will be a bit more difficult (we don't use native calls for them and the JDK socket classes don't have "pair" capability).

@ojab
Copy link
Author

ojab commented May 26, 2015

MRI also supports pair only for UNIX sockets (other fails with Errno::EOPNOTSUPP), but it can be called not only using UNIXSocket.pair, but also using Socket.pair(:UNIX, :type, :protocol).
So there is only Socket.pair/Socket.socketpair methods missing.

@headius
Copy link
Member

headius commented May 26, 2015

@ojab thanks for looking into that. I also noticed that BSD socketpair(2) only supports UNIX as well. So we'll implement it to just call UNIXSocket.pair and error for other types.

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

No branches or pull requests

3 participants