Binding Java Socket with each loopback address

How can I bind Java Socket to listen to every return address?

http://en.wikipedia.org/wiki/Localhost "The IPv4 networking standard reserves the entire 127.0.0.0/8 block of addresses for loopback purposes. This means that any packet sent to one of these 16,777,214 addresses (from 127.0. 0.1 to 127.255.255.254) will be looped back. "

The current implementation only binds to localhost / 127.0.0.1 using SocketImpl.bind (host InetAddress, int port). This was on the assumption that the hostname would be resolved in the same way as localhost, i.e. 127.0.0.1, but it looks like on linux the hostname might be bound to 127.0.1.1 (e.g. see https://serverfault.com / questions / 363095 / why-does-my-hostname-appear-with-the-address-127-0-1-1-rather-than-127-0-0-1-in ).

Other software locally uses the hostname of the computer to resolve which IP address is connecting => trying to connect to 127.0.1.1, which the server is not listening on as it only binds to 127.0.0.1.

This answer to the server response question links to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316099 which says "most services listening locally listen on all 127/8 addresses , not only 127.0.0.1 ". So what would I like to do.

Is there a way to do this? or I hope that binding to 127.0.0.1 and 127.0.1.1 is enough?

+3


source to share





All Articles