Skip to content

Inconsistent behaviour on TCPSocket#recvfrom #1550

Open
@sponomarev

Description

@sponomarev

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:

addrinfos = Socket.getaddrinfo(addr.ip_address, nil, addr.afamily,
addr.socktype, addr.protocol, 0, true)

addr = Addrinfo.new([Socket::AF_UNSPEC], nil, socket_type)

Unfortunately, I have no idea about the motivation for these decisions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions