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);
        }
    }
}