BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 07-31-2008, 11:07 AM   #1 (permalink)
Knows Where the Search Button Is
Join Date: Jun 2008
Model: pearl
Carrier: none
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ServerSocketConnection

Please Login to Remove!


I am trying to make a j2me server that would listen for incomming requests. I create a socket conmnection for the same and try to listen port. However the simulator seems to open the socket (based on debug info only) but there is no external connection or access. Even another internal program on the simulator cannot access the server on the specified port .

On further investigation it turns out that the getlocaladdress method returns weird characters and System.getProperty on hostname returns null.

Any idea what the problem might be? it should be with the ports and opening and something there ? Any help would be greatly appreciated.

The code is as follows:
public void run(){
				ServerSocketConnection server= null;
				try {
					server = (ServerSocketConnection)"socket://:"+port);
					update("server started on port "+ server.getLocalPort()+" "+ server.getLocalAddress()+"on "+System.getProperty("microedition.hostname"));
				} catch (IOException e1) {

				while (true) {
					try {
						SocketConnection client;

						client = (SocketConnection) server.acceptAndOpen();
Old 07-31-2008, 12:59 PM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts

I don't think this will work unless your blackberry is provisioned with a public IP address. With our carrier we can do this by subscribing to VPN support, other wise I believe the device is behind a NAT wireless to IP gateway of some kind.

The only way I've found to do what you want is by using the MDS push protocol (which has a similar pattern to the server socket) that comes along with the BES and Unite servers. The MDS simulator provides the same for the BB simulator.

It is possible that a recently announced protocol called Web Signals may provide the same capabilities without BES/Unite but I'm still waiting for detailed information from RIM on that. If you are a member of, or qualify for membership in the Blackberry Developer Network information is available there, apparently.

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.