Results 1 to 1 of 1
Thread: Midlet - While loop won't run?
- 09-20-2009, 01:40 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
Midlet - While loop won't run?
Hi!
I'm trying hard to get a Java MIDlet server and a Phyton in connection via a datagramconnection. My problem is atm. very simple - i can't get the loop there is supposed to listen for client calls to loop? (DOH!). My experience with MIDlets is very limited (almost none), so i wonder whats wrong..
I really hope someone will check my simple MIDlet and give me a kick in the right direction..:o
Java Code:import javax.microedition.io.Connector; import javax.microedition.io.Datagram; import javax.microedition.io.DatagramConnection; import javax.microedition.midlet.*; /** * @author admin */ public class Midlet extends MIDlet { public Midlet() { } public void startApp() { serverstart(); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void serverstart() { try { DatagramConnection receiver = null; receiver = (DatagramConnection) Connector.open("datagram://localhost:8081"); byte[] buffer = new byte[256]; Datagram dgram = receiver.newDatagram(buffer, buffer.length); while(true){ dgram.setLength(buffer.length); // Wait for somebody to call... receiver.receive(dgram); // Set string and store in buffer String text = "This is the reply"; byte[] dataBytes = text.getBytes(); System.arraycopy(dataBytes, 0, buffer, 0, dataBytes.length); // Send back the reply dgram.setLength(dataBytes.length); receiver.send(dgram); } } catch (Exception ex) { System.out.println("Something went wrong.. " + ex); } } }
Similar Threads
-
sms midlet
By Poonam in forum CLDC and MIDPReplies: 3Last Post: 11-25-2009, 02:47 PM -
while-loop stopping on first loop
By davester in forum New To JavaReplies: 6Last Post: 06-26-2009, 08:46 PM -
want to run my midlet in background!
By jackofall in forum CLDC and MIDPReplies: 1Last Post: 03-31-2009, 07:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks