• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

J2ME socket

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
 
reply
    Bookmark Topic Watch Topic
  • New Topic