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.

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.

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.

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.

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

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.

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());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.