• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

J2ME for socket  RSS feed

 
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to check out http://www.beacontower.net.
 
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:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!