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
Highlighted
Developer
Posts: 37
Registered: ‎10-17-2008
My Device: Not Specified

getLocalAddress() fails with TCP but works with UDP

On the 4.5 emulator...

 

The following code returns null for the local address:

 

 

ServerSocketConnection serverSoc = (ServerSocketConnection) Connector.open("socket://:6543;interface=wifi");
String localAddress = serverSoc.getLocalAddress();
System.out.println("Localaddr: " + localAddress); // <---- always null!

 

 but if I switch to UDP it works:

 

 

UDPDatagramConnection serverSoc = (UDPDatagramConnection) Connector.open("socket://:6543;interface=wifi");
String localAddress = serverSoc.getLocalAddress();
System.out.println("Localaddr: " + localAddress); // <---- gives valid ip

 

 Is this a bug or am I doing something wrong?

 

 

BlackBerry Development Advisor
Posts: 15,700
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: getLocalAddress() fails with TCP but works with UDP

The BlackBerry Simulators do not support simulating Wi-Fi connections.  You'll need a real device to test this.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker