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
New Developer
timtim
Posts: 1
Registered: ‎02-25-2009
My Device: Not Specified

ServerSocketConnection

[ Edited ]
Hello,
I am trying to create a server socket on my BB 8120 v4.3.0.115 while using only WiFi (no sim card in the device).
For that I tried the sample given in the documentation under Interface ServerSocketConnection.
I modified theConnector.open call by passing it Connector.open("socket://:15234";interface=wifi);
I am using JDE 4.3.0.

Meanwhile I also checked the SocketDemo example provided with the api. It works for Computer (server) -- BB device (client) configuration using WiFi on the same device.

Seems that the serverSocket does get created on the device, just that no communication takes place.
It keeps on waiting on the call to acceptAndOpen().
I tried connecting to the serverSocket by doing -- "telnet 172.16.1.150 15234" from the computer command prompt.
I spawned a new thread and have the following code in the run():

String url = "socket://:15234;interface=wifi"; scn = (ServerSocketConnection) Connector.open(url); System.out.println("server socket conn = " + scn.toString()); System.out.println("address = " + scn.getLocalAddress()); System.out.println("port = " + scn.getLocalPort()); System.out.println("wait for an incoming connection"); // Wait for a connection. sc = (SocketConnection) scn.acceptAndOpen();

...

...

..

I see the following output:

 

server socket conn = net.rim.device.cldc.io.tcp.TcpServerSocketConnection@3bc630f
address = 172.16.1.150
port = 15234
wait for an incoming connection

 

Am I missing something here?
Thanks.
Message Edited by timtim on 02-25-2009 09:25 PM
Please use plain text.
Developer
smartfish
Posts: 136
Registered: ‎02-12-2009
My Device: Not Specified

Re: ServerSocketConnection

Hi,

may be you should try this,

 

String url = "socket://172.16.1.150:15234;deviceside=true;interface=wifi";
scn = (ServerSocketConnection) Connector.open(url);
 

 

If this works mark it as SOLUTION!!

 

Regards

SmartFish

_____________________________________________________________________

Thank the person who helped you by clicking Kudos! star near their post..
If you start a new thread, then resolve it using Accepted Solution button..
Leave solved threads for reviewing purposes - Start a new thread for new questions..
Please use plain text.
Developer
amardeepjaiman
Posts: 293
Registered: ‎02-25-2009
My Device: Not Specified

Re: ServerSocketConnection

Can we assign , an IP address to my serversocket on BB device? your code is hanging my device.
Please use plain text.
New Developer
tiggit
Posts: 9
Registered: ‎03-04-2009
My Device: Not Specified

Re: ServerSocketConnection

 



 

String url = "socket://172.16.1.150:15234;deviceside=true;interface=wifi";
scn = (ServerSocketConnection) Connector.open(url);
 

 

 


 

 

Your original code is correct. The code above will create a client connection to the nominated address. The code below should work, however there are considerations about the devices you might use. If you are using a simulator before OS 5.0 you will probably need to drop the interface=wifi part.

 

String url = "socket://:15234;deviceside=true;interface=wifi";
Please use plain text.
Developer
peter_strange
Posts: 19,598
Registered: ‎07-14-2008
My Device: Not Specified

Re: ServerSocketConnection

I was not aware that it was possible to set the IP Address of a BlackBerry device, except possibly the WiFi Address, but even then it would have to match the network in which it was connected.

 

Are you sure this code is correct?

 

Please use plain text.