![]() |
| ||
| Host's Non-Local IP Address Hello, I was just wondering if it is possible in Java to get the host's IP address, as seen on the Internet, not network or by the computer itself. I mean, getting something like 87.253.145.35 instead of something like 192.168.1.100 or 127.0.0.1. Or, if not, is there any popular/known server that has a static IP address with which I could open a Socket and have it tell me my IP address? |
| ||
| Re: Host's Non-Local IP Address I don't know how its done, but here is an example |
| ||
| Re: Host's Non-Local IP Address Ah, well, that won't really work in Java by itself, but, for those who care, this works (by utilizing a website like the one above): try {If I could figure out what the index URL for whatismyip.org is (which has only 1 thing on it: the IP address), that would be even better. I've tried a lot of extensions to "index" and some to "default".... |
| ||
| Re: Host's Non-Local IP Address Hi everyone, Try looking at the java's InetAddress api, there maybe something useful there for you http://java.sun.com/j2se/1.5.0/docs/...etAddress.html Richard West |
| ||
| Re: Host's Non-Local IP Address Well, I have tried using that, and unless there is something I'm missing, that only gives addresses such as 192.168.1.100 when used with getLocalHost().getHostAddress();. I was looking for the global/public IP address. |
| ||
| Re: Host's Non-Local IP Address Hi everyone, see the below threads http://forum.java.sun.com/thread.jsp...62802&tstart=0 http://forum.java.sun.com/thread.jsp...hreadID=592585 http://forum.java.sun.com/thread.jsp...hreadID=520999 http://forum.java.sun.com/thread.jsp...hreadID=639572 http://sharkysoft.com/tutorials/jsa/content/040.html http://forum.java.sun.com/thread.jsp...hreadID=143409 http://www.java-tips.org/java-se-tip...an-applet.html http://forum.java.sun.com/thread.jsp...hreadID=218845 http://forum.java.sun.com/thread.jsp...hreadID=269203 Richard West |
| ||
| Re: Host's Non-Local IP Address All of those do not give the public IP address, except the fourth one (http://forum.java.sun.com/thread.jsp...hreadID=639572). However, the way suggested is just what I had thought of and implemented above. |
| ||
| Quote:
public String getMyPublicIP(){ |
| All times are GMT -4. The time now is 7:45 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC