Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot create socket using ServerSocketConnection on AT&T Tilt phone

 
Harsha Girish
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am a newbie to J2ME. My intention is to have a phone listen on port 4444

I have the following code to listen

ServerSocketConnection ssc=null;

//#debug error
System.out.println("Waiting for message on socket://:"+4444);
try {
ssc = (ServerSocketConnection)Connector.open("socket://:" + 4444);
} catch (IOException e) {
// TODO Auto-generated catch block
log(e.toString());
e.printStackTrace();
}



The log function I have defined is

public void log(String msg) {
try {
fc = (FileConnection)Connector.open("file:////mylog.txt");
dosf = fc.openDataOutputStream();
dosf.writeUTF(msg);
dosf.flush();
dosf.close();
fc.close();
} catch (IOException e) {
e.printStackTrace();
}
}


it results in an a exception on AT&T Tilt phone (which does not yet have a sim card and hence is not using GPRS).
the exception message is

javax.microedition.io.ConnectionNotFoundException: Cannot create socket,//:4444

However the same code works on Nokia N95.

Please help me. I am badly stuck up and I have found nobody else having the same problem.

For your information:
AT&T Tilt phone has a Windows Mobile 6 OS and runs Esmertec Jbed JVM. It has CLDC 1.1/MIDP 2.0 specification.


Thanks,
Harsha
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible that for security reasons, this particular system only allows opening listener connections on selected ports.

One thing you might try, however, is to code the URL as "localhost:4444" instead of an implied host. Just in case it's not smart enough to figure that out.
 
Harsha Girish
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I found the problem. It appears that the JBed JVM has a problem with listening on a port. Be it ServerSocketConnection or DatagramConnection. the error is the same.

I found a way around this problem. I installed a Creme JVM (which is free for evaluation) and this is a CDC JVM which does not have support for stream sockets but does have support for datagram sockets. The datagram socket seems to be working well, even though I have to take care of the reliability aspect.

Harsha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic