aspose file tools*
The moose likes Java Micro Edition and the fly likes get phone ip address in J2ME Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "get phone ip address in J2ME" Watch "get phone ip address in J2ME" New topic
Author

get phone ip address in J2ME

Allen Chao
Greenhorn

Joined: Jul 15, 2004
Posts: 4
I have a problem to get phone IP address. I opened a serverSocket connection, and called the method getLocalAddress(). What I got is 127.0.0.1. Could someone help me to figure out how to get cellphone address using J2ME please?

Thank you.
Allen Chao
Greenhorn

Joined: Jul 15, 2004
Posts: 4
If phone IP address couldn't be got, how could external program connect to a serverSocket in cellphone?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Well getLocalAddress is the correct method to call to get the Phone's listening address, and getLocalPort to get the port.

I think you are currently running this through the emulator, and it returns your localhost IP address, which makes sense.

The big trick is publishing the devices address and port so that the outside can connect to you device.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
manoj pillai
Ranch Hand

Joined: Sep 16, 2002
Posts: 41
Actually I think it depends on the provider, whether your connection is via a proxy or not. If the proxy doesnt allow inward connections, you are outta luck; which is what happened in my case


SCJP,SCJD,SCEA,SCMAD,SCDJWS,SCJP5.0
Allen Chao
Greenhorn

Joined: Jul 15, 2004
Posts: 4
Thank you very much for your comments. In fact, I am really using Nokia 6600 instead of emulator. And the carrier is Canada Rogers AT&T.

If it is the provider or proxy problem, is there a workaround to connect to a socketserver from outside?

Thanks.

Allen
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Originally posted by Allen Chao:
If it is the provider or proxy problem, is there a workaround to connect to a socketserver from outside?


No, even if you do find a workaround, it is probably illegal and breaches your service contract. The best way to push connections to the phone is via a SMS message addressed to a specific port listened by the Java app.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get phone ip address in J2ME