Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2ME socket

 
Carlos Garza
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

First sorry for my english, i'm a little bad with it=P :roll:

My partner and me are developing an application in midlets that has to communicate by sockets with an J2SE applicaction, the communication its all right, at this moment only the MIDlet send the information to J2SE application, but i need to send a string variable through a socket to the MIDlet from the J2SE application, does anybody knows how to do this, or have an idea

thanks for all
[ May 27, 2005: Message edited by: Carlos Garza ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now if the socket connection is still open for the information your Midlet sent to the J2SE JVM, then you can use the same socket.

Otherwise you need to use the ServerSocketConnection object, this will allow socket to connect to the mobile device. The fun trick is that the mobile device's IP needs to be "broadcast"/publish, so that the outside world can open that connection. You will also probably want to look at the PushRegistry, so that the Socket connection can occur without the Midlet have to be running at that moment.

Mark
[ May 28, 2005: Message edited by: Mark Spritzler ]
 
Eduardo Marques
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your only trouble is really writing the string then you can use the following code, (assuming SocketConnection on the J2ME client side):

SocketConnection sc = ...;
DataOutputStream dos = sc.openDataOutputStream();
String s = "STRING";
dos.writeUTF(s);
dos.flush();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic