The IPv6 host :: is kind of analogous to the IPv4 address 0.0.0.0, however it should usually (depending on the OS) listen for traffic coming from IPv4 and IPv6 addresses, unless specified differently by the OS.
However, i have observed that across different linux distros i have tried (manjaro, arch, debian), WEBRick will open its socket in ipv6-only mode.
I assume that the reason is this line as using the Socket.tcp_server_sockets function manually leads to the same result.
However, e.g. using the TCPServer from the socket stdlib opens a socker that's not in ipv6-only mode.
Sample code i have used:
require 'webrick'
server = WEBrick::HTTPServer.new Port: 8080, Host: '::', DocumentRoot: '~/'
trap 'INT' do
server.shutdown
end
server.start
I have tested this with webrick 1.7.0 on ruby 3.1.1 and on ruby 2.6.3, both yielding the same result.
I have observed the mode using ss -tlne, where the local address is shown as [::]:8080, which indicates ipv6-only mode in ss, while it should be *:8080 in non-ipv6-only mode.
It also says v6only:1 in the process description, while it should say v6only:0.
Also here's the sample code using TCPServer that correctly opens the socket:
require 'socket'
server = TCPServer.new('::', 8080)
loop do
client = server_socket.accept
client.puts 'hello'
client.close
end
The IPv6 host
::is kind of analogous to the IPv4 address0.0.0.0, however it should usually (depending on the OS) listen for traffic coming from IPv4 and IPv6 addresses, unless specified differently by the OS.However, i have observed that across different linux distros i have tried (manjaro, arch, debian), WEBRick will open its socket in ipv6-only mode.
I assume that the reason is this line as using the
Socket.tcp_server_socketsfunction manually leads to the same result.However, e.g. using the
TCPServerfrom thesocketstdlib opens a socker that's not in ipv6-only mode.Sample code i have used:
I have tested this with webrick 1.7.0 on ruby 3.1.1 and on ruby 2.6.3, both yielding the same result.
I have observed the mode using
ss -tlne, where the local address is shown as[::]:8080, which indicates ipv6-only mode inss, while it should be*:8080in non-ipv6-only mode.It also says
v6only:1in the process description, while it should sayv6only:0.Also here's the sample code using
TCPServerthat correctly opens the socket: