Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

How to get my hostname and local ip address

Hi, i am trying to get my hostname in jde4.2 and the ip address that my BB has any idea how to get this data?

thanks

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to get my hostname and local ip address

Not really my area, but here is a quick answer.  Hopefully someone else will provide a fuller answer later.

 

Unless you are connecting wirelessly, which I don't think is supported in OS 4.2, you do not have a network IP Address or Host Name.  All your IP Traffic is tunneled to you via what is effectively a NAT box or proxy service - either provided by carrier for direct TCP, or via the MDS for BES/MDS connection.

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: How to get my hostname and local ip address

You can always have a server report it back to you but more directly

SocketConnection.getLocalAddress() is supposed to work but I've never tried it.

It further claims,  

"The local hostname (if available) can be accessed from System.getProperty("microedition.hostname")

 

If you initiate a connection, the peer can reply to whatever IP is advertised but

it would be nice to find a general means, even if carrier specific, of fixed originated

connection addressing. If you do find locally available interesting hostnames, please post some here and I'll try

to hit you from my desktop.

 

If you just want to talk to yourself, usually 127.0.0.1 will work.

I don't see anything in RIM class list that is obviously similar to InetAddress

http://www.google.com/search?hl=en&q=site%3Asun.com+local+ip+address&aq=f&oq=

 

 

Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

Re: How to get my hostname and local ip address

this System.getProperty("microedition.hostname") returns alwaus null while the getLocalAddress() give me an apipa address, i think that i have to search something different.
New Developer
Posts: 2
Registered: ‎11-07-2008
My Device: Not Specified

Re: How to get my hostname and local ip address

Hi jllarraz:

 

    i got the same issue; have you found out how to get them yet??

 

Thanks

Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

Re: How to get my hostname and local ip address

the only way taht i found to do this is create a udp connection and get the localaddress()