• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get phone ip address in J2ME

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If phone IP address couldn't be got, how could external program connect to a serverSocket in cellphone?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
please buy my thing and then I'll have more money:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic