How to get IP address of the Host ?

I want to write a applet to fetch the IP address of the Host ISP to which i am connecting to. Since i am using a dial up connection the IP address changes every time i connect. I need th IP address for developing a Mail Server.

Please give the code which to get the connectiong ISP's IP address. I am able to get the local IP address using getlocaladdress() method of Network package.

Expecting a early reply

Sriram
sriram_comAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ravindra76Commented:

Hi,

 I have one doubt.

 Applet will load from server.
 i.e your applet has to be laod form your ISP. will he agree?

Suppose he agrees,

How will you connect to server through?

Through Sockets or URLConnection?

If you are creating sockets, give His server name.
Ip address will change but not the servername.

For URLConnection also same is true.
0
gadioCommented:
try :
URL url  = myapplet.getCodeBase()

and then

String host = url.getHostName();

InetAdress[] addresses = InetAddress.getAllByName(host);
0
gadioCommented:
Then for each of the addresses use
byte[] bytes = adress[i].getAddress();
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

heyhey_Commented:
if you are trying to obtain this address from local applet or application - there is no platform independent solution (i.e. you'll need some native code)
0
vladi21Commented:
if ur applet on server:

Get the client IP address
import java.net.*;
import java.io.*;
import java.applet.*;

public class GetClientIP extends Applet {
  public void init() {
    try {
     InetAddress thisIp =
        InetAddress.getLocalHost();
     System.out.println("IP:"+thisIp.getHostAddress());
     }
    catch(Exception e) {
     e.printStackTrace();
     }
    }
}
 


<HTML><HEAD></HEAD><BODY>
<APPLET CODE="GetClientIP.class"  
      HEIGHT=10 WIDTH=10>
 </APPLET>
 Check JAVA console for output
</BODY></HTML>
 


Try it here http://tactika.com/realhome/examples/GetIP.html
NOTE: Netscape returns the IP address with the default security settings so it's not problem. With IE5, you must go to the security TAB, Internet, Java Custom, Edit and select "Allow access to all IP address".


if ur applet on local machine - maybe u need application - not applet
what ur OS/platform?
0
vladi21Commented:
r u still need help
0
vladi21Commented:
if ur applet on server:

Get the client IP address
import java.net.*;
import java.io.*;
import java.applet.*;

public class GetClientIP extends Applet {
  public void init() {
    try {
     InetAddress thisIp =
        InetAddress.getLocalHost();
     System.out.println("IP:"+thisIp.getHostAddress());
     }
    catch(Exception e) {
     e.printStackTrace();
     }
    }
}
 


<HTML><HEAD></HEAD><BODY>
<APPLET CODE="GetClientIP.class"  
      HEIGHT=10 WIDTH=10>
 </APPLET>
 Check JAVA console for output
</BODY></HTML>
 


Try it here http://tactika.com/realhome/examples/GetIP.html 
NOTE: Netscape returns the IP address with the default security settings so it's not problem. With IE5, you must go to the security TAB, Internet, Java Custom, Edit and select "Allow access to all IP address".


if ur applet on local machine - maybe u need application - not applet
what ur OS/platform?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
heyhey_Commented:
'if ur applet on local machine - maybe u need application - not applet
what ur OS/platform?'

so you call THIS ANSWER ?

it's easy to lock October questions to get some more points ... but not very ethic...

my 2 c
0
vladi21Commented:
but i am waiting comments from sriram_com ....
0
heyhey_Commented:
>> but i am waiting comments from sriram_com ....

sriram_com hasn't opened this page from 27 oct :)

happy y2k :)
0
vladi21Commented:
0
heyhey_Commented:
you know ... it happens
last time YOU got my points :)

shaveri is blacklisted
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.