You Are Here:

Community: Developer Discussion Boards

#1 Old Can I get the IP address of the mobile using J2ME? - 2004-04-09, 11:53

Join Date: Jul 2003
Posts: 20
pop2518
Offline
Registered User
Hi..

Is there possible way to get the IP address that assigned
to the mobile while it connected to some host?

Voravit H.
Reply With Quote

#2 Old 2004-04-09, 14:48

Join Date: Mar 2004
Posts: 16
phoumlib
Offline
Registered User
Hi

if you have your own web server, you can return the remote host variable to the midlet.

Or simply make a connection from the midlet to some web sites that return the ip address such as http://www.whatismyip.com/
Reply With Quote

#3 Old 2004-04-09, 15:14

Join Date: Jul 2003
Posts: 32
ggould
Offline
Registered User
phoumlib's suggestion may not actually tell you what you want to know.

On a typical carrier network, the phone is behind a NAT firewall. The phone itself has a non-routable IP address (usually 10.somthing). When it connects to something outside, the NAT firewall rewrites the address headers so that the connection seems to have come from the NAT itself. Thus whatismyip.com will report the external IP address of the carrier network's NAT box rather than that of the phone.

If for some reason you want the IP address of the phone, you can only get this in MIDP-2 -- MIDP-1 doesn't have the capability. In MIDP-2, establish a connection to any external host, then use the Connection.getLocalAddress() method on this connection. This may only work if you have actually sent some data on this connection, though: If the GPRS connection is idle, getLocalAddress() may just report 127.0.0.1.

Note that the IP address of the phone is NOT something that you can connect to from outside -- it's generally a non-routable address -- and is NOT guaranteed to be stay the same if the phone roams between cells. Unless you're using a protocol like STUN, you are probably going in a wrong direction looking at the phone's address.
--G
Reply With Quote

#4 Old 2004-04-12, 04:18

Join Date: Jul 2003
Posts: 20
pop2518
Offline
Registered User
Thank you for your kindness :D
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia