truffleruby
truffleruby copied to clipboard
Inconsistent behaviour on TCPSocket#recvfrom
Here is a scenario to reproduce
# server.rb. No matter on which Ruby version it's running
require 'socket'
server = TCPServer.open(2000)
loop {
Thread.start(server.accept) do |client|
client.puts "Hello world"
client.close
end
}
# client.rb
require 'socket'
socket = TCPSocket.open('localhost', "2000")
puts socket.recvfrom(2000)
# Server closes the connection here
puts socket.recvfrom(2000)
MRI result
$ ruby client.rb
Hello world
Truffle result
$ ruby client.rb
/Users/toad/.rbenv/versions/truffleruby-1.0.0-rc10/lib/truffle/socket/addrinfo.rb:207:in `ip_address': An IPv4/IPv6 address is required (SocketError)
from /Users/toad/.rbenv/versions/truffleruby-1.0.0-rc10/lib/truffle/socket/ip_socket.rb:48:in `recvfrom'
from client.rb:5:in `<main>'
The underlying reason for the failure is here: https://github.com/oracle/truffleruby/blob/ab0dda45f362e434ea9219723fd0e82a003f07f1/lib/truffle/socket/ip_socket.rb#L53-L54 https://github.com/oracle/truffleruby/blob/ab0dda45f362e434ea9219723fd0e82a003f07f1/lib/truffle/socket/basic_socket.rb#L204
Unfortunately, I have no idea about the motivation for these decisions.