• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2ME for socket

 
ying qu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
Can "J2ME Wireless Toolkit" support socket protocol?
I try to open a server-side socket in the emulator and I program like this:
server = (StreamConnectionNotifier)Connector.open("socket://127.0.0.1:1234");
but IOException and NullPointerException are thrown.
Is there anything wrong in my program or the J2ME Wireless Toolkit doesn't support this?
Thanks a lot in advance!!
Best Regards!

Ying
 
Hearth Stone
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to check out http://www.beacontower.net.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ying qu:

server = (StreamConnectionNotifier)Connector.open("socket://127.0.0.1:1234");
but IOException and NullPointerException are thrown.

Your code tries to open an socket connection to port 1234 on local machine. If you do not have a server running at that port already (you do not, since you attempt to open a server port here), you will have an IO Exception.
To open server port, you can try to use datagram sockets:
Examples:
Datagram-based Socket - listening
datagram://:1234
Datagram-based Socket - sending
datagram://127.0.0.1:1234
I am not complete sure whether this will work. But you can try and let us know.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some additional notes: The implementation of socket (inlcuding server socket) is completely dependent on the phone vendor and even the wireless carrier. On Motorola's i95cl, you can open a server port using:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic