thanks helping me. trying run more 1 server in java program code:
addr = inetaddress.getbyname("127.0.0."+myip); ss = new serversocket(port,100,addr); but code works myip=1,is there way solve this?
if asking if system can have multiple 127.x.x.x addresses, answer "it depends on os, , network configuration".
on linux / fedora 20 box, "/etc/sysconfig/network-scripts/ifcfg-lo" defines of 127.0.0.0/8 loopback addresses. however, if @ file, implication "lo" device configured allow fewer addresses (or if crazy) other addresses loopback ip addresses.
on mac osx, 127.0.0.1 loopback address configured default, easy configure more (see references).
from have read, on windows 7 there 1 loopback address - 127.0.0.1. hard-wired, , treated specially networking stack. windows have "loopback adapter" purpose different.
tl;dr - code work on linux, not on windows. on mac os/x need tweak network configs make work.
references:
- http://www.hsc.fr/ressources/articles/win_net_srv/missing_loopback.html
- https://technet.microsoft.com/en-us/library/cc708341%28v=ws.10%29.aspx
- https://superuser.com/questions/458875/how-do-you-get-loopback-addresses-other-than-127-0-0-1-to-work-on-os-x
if asking if can bind multiple ip addresses single serversocket, answer "no".
a serversocket can bound @ 1 ip address.
if want listen / accept using multiple ip addresses, need use multiple serversocket instances.
however, ip address 0.0.0.0 called "local wildcard" address. if bind this, binding ip addresses of network interfaces (including loopback interfaces)
see also:
Comments
Post a Comment