i have been trying to write some programs on java sockets and i got stuck with this problem.
Normally the INetAddress object is created using the factory methods getLocalHost(), getbyAddress(byte[]) and getbyName(string)…. when I use getbyName function…
for example…
INetAddress a=InetAddress.getbyName("www.google.com");
and trying to print the above object using println method i was getting Unknown host exception but actually i heard that it would perform a DNS query and return one of the IP address of a server of google.com but its not working that way… i used netbeans to run the program and our college has a proxy server also.
One more thing… if i use the getbyName(string) and give an argument as some others PC name who is within the college network then can it resolve the system IP address ? . In my case this was unable to resolve..
I checked by turning the windows firewall to off state also but in vain….
please help…
ping www.google.com is showing “ping request could not find the host name google.com”
The name resolution strategy used by
InetAddress.getByNamedepends on the operating system. If the OS is configured to use DNS to resolve names, that’s whatInetAddress.getByNamewill use. (Probably.)To check that DNS is working correctly you can run
nslookup www.google.comfrom a terminal.If other programs on your system can resolve the name to an IP address so should Java.