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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
branchcut
Posts: 37
Registered: ‎10-17-2008

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?

 

 

Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
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.
Found a bug? Report it using the Issue Tracker
Please use plain text.