0

Hi!

I was wondering if there's a way to view the IP address of a certain site through Command Prompt. Even better, maybe there's a way to access it through a c++ or java program!

thanx.

4
Contributors
7
Replies
8
Views
12 Years
Discussion Span
Last Post by server_crash
0

Even better, maybe there's a way to access it through a c++ or java program!

thanx.

You can access a site through java without knowing the IP Address. look up the java.net.*; package.

0

server_crash, thanx but i already know that. I wanted 2 make a program that tells u the ip address of the inputted domain name.

thanx anyway.

0

server_crash, thanx but i already know that. I wanted 2 make a program that tells u the ip address of the inputted domain name.

thanx anyway.

The ping command referenced in Catweazle's link will return the IP, although by default it will query a site 4 times, echo a response for every query, and then barf summary statistics on top of that. You can limit the query count with the "-n" switch, but it will still return the stats as well.

You might also check out the "nslookup" command.

0

thanx. one more question. is there a way to return the ip address to a java/c++ program?

0

thanx. one more question. is there a way to return the ip address to a java/c++ program?

This is how you can grab the client ip address:

InetAddress thisIp =
        InetAddress.getLocalHost();
     System.out.println("IP:"+thisIp.getHostAddress());

Remember to include that in a try catch clause, as that code could potentially cause an exception.

Also, writting a simple servlet would be easier:

String IP = req.getRemoteAddr();

req is an HTTPServletRequest Object.

0

Sorry, you might want to get it by the hostname:

java.net.InetAddress inetAdd =
java.net.InetAddress.getByName("www.ibm.com");
	System.out.println ("IP Address is : " + inetAdd.getHostAddress());
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.