By default, a ServerSocket will listen on all available network interfaces, including each Ethernet card and localhost, as well as all virtual IP addresses mapped to the Ethernet cards. You can restrict this by IP or hostname. This example is taken from Chapter 10, Sockets for Servers:
For example, login.ibiblio.org is a particular Linux box in North Carolina. It�s connected to the Internet with the IP address 184.108.40.206. The same box has a second Ethernet card with the local IP address 192.168.210.122 that is not visible from the public Internet, only from the local network. If for some reason I wanted to run a server on this host that only responded to local connections from within the same network, I could create a server socket that listens on port 5,776 of 192.168.210.122 but not on port 5,776 of 220.127.116.11, like so:
Elliotte Rusty Harold<br />Author of <a href="http://cafe.elharo.com/web/refactoring-html/" target="_blank" rel="nofollow">Refactoring HTML</a>
posted 15 years ago
Ah, makes sense each card would have its own IP address. Hard to believe I actually passed a network class once I was wondering if we could tie this back to the original request and make a Java software ethernet-to-serial solution, or any kinda input to any kinda output. That is pretty much the whole magic of "inter" in the Internet.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi