This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get phone ip address in J2ME

 
Allen Chao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If phone IP address couldn't be got, how could external program connect to a serverSocket in cellphone?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
manoj pillai
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Allen Chao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic