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
PIN: N/A
Carrier: none
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ServerSocketConnection

Please Login to Remove!

Hello

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:
Code:
public void run(){
				ServerSocketConnection server= null;
				try {
					server = (ServerSocketConnection)Connector.open("socket://:"+port);
					update("server started on port "+ server.getLocalPort()+" "+ server.getLocalAddress()+"on "+System.getProperty("microedition.hostname"));
				} catch (IOException e1) {
					e1.printStackTrace();
				}

				while (true) {
					try {
						
						SocketConnection client;

						client = (SocketConnection) server.acceptAndOpen();
...
Offline  
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
Default

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.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.