Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-17-2009, 08:55 PM
Member
 
Join Date: Apr 2009
Posts: 6
Rep Power: 0
Godsent is on a distinguished road
Default Get Ip adress?
Is where any way to get IP address the same you can look at at websites like ipchicken.com or whatismyip.com ?

I tried many tutorials and all of them obtain Default Gateway. Anyone can help me?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-17-2009, 09:08 PM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
The IP address you get from whatismyip will be the external IP address of your router or equivalent, which has a separate IP address for your local network side. Only external servers can see the external IP, while you can only see the local IP. Try connecting a socket to an external server and asking what your IP is.
__________________
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-11-2009, 03:15 PM
Member
 
Join Date: Jul 2009
Location: bhubaneswar
Posts: 5
Rep Power: 0
lipun4u is on a distinguished road
Default
If u want to know ur own ip address ..the following code may help u...

Quote:

import java.util.*;
import java.net.*;
import java.net.NetworkInterface;

public class InetAssressExample {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Enumeration<NetworkInterface> interfaceList = NetworkInterface.getNetworkInterfaces();
if (interfaceList == null)
System.out.println("Error");
else {
while(interfaceList.hasMoreElements()) {
NetworkInterface iface = interfaceList.nextElement();
System.out.println("Interface : " + iface.getName() + " :: ");
Enumeration<InetAddress> addrList = iface.getInetAddresses();
if(!addrList.hasMoreElements()) {
System.out.println("\t(No address for this interface");
}
while(addrList.hasMoreElements()) {
InetAddress address = addrList.nextElement();
System.out.println("\tAddress " + ((address instanceof Inet4Address ? "(v4)"
: (address instanceof Inet6Address ? "(v6)" : "(?)"))));
System.out.println(": " + address.getHostAddress());
}

}
}
}catch(SocketException se) {
System.out.println("Error getting network interfaces : " + se.getMessage());
}

}

}
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 06:59 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org