J
Jonas Hei
Hi,
I need to build an application for the siemens tc45 cellular engine.
It supports j2me. I have not been able to find any example code for doing
UDP (datagram) commuication using the J2ME (MIDP or siemens implementation
of MIDP [called as IMP]).
I have pasted the code below - it however doesn't seem to work. I have not
tried executing it in the tc45 yet, but when I execute it in the emulator
it hangs (doesn't return) on the method dgc.send(dg).
Any ideas, tips in general or specifically related to datagram client
implementation will be greatly appreciated.
Thanks.
The code:
import javax.microedition.midlet.*;
import java.io.*;
import javax.microedition.io.*;
import java.util.*;
import com.siemens.icm.io.*;
public class One extends MIDlet {
public One() {
}
public void init() throws MIDletStateChangeException {
}
public void startApp() throws MIDletStateChangeException {
doWork();
sendMessage();
notifyDestroyed();
}
public void sendMessage() {
try {
DatagramConnection dgc = null;
dgc = (DatagramConnection)
Connector.open("datagram://192.32.80.192:9001");
String datastring = "such and such work done";
byte[] buf = datastring.getBytes();
Datagram dg = dgc.newDatagram(buf,datastring.length());
//dg.setAddress("datagram://192.32.80.192:9001");
dgc.send(dg);
dgc.close();
}
catch(IllegalArgumentException e3) {
System.out.println(e3);
}
catch(InterruptedIOException e1) {
System.out.println(e1);
}
catch(IOException e) {
System.out.println(e);
}
}
public void pauseApp() {
}
public void destroyApp(boolean cond) {
}
}
I need to build an application for the siemens tc45 cellular engine.
It supports j2me. I have not been able to find any example code for doing
UDP (datagram) commuication using the J2ME (MIDP or siemens implementation
of MIDP [called as IMP]).
I have pasted the code below - it however doesn't seem to work. I have not
tried executing it in the tc45 yet, but when I execute it in the emulator
it hangs (doesn't return) on the method dgc.send(dg).
Any ideas, tips in general or specifically related to datagram client
implementation will be greatly appreciated.
Thanks.
The code:
import javax.microedition.midlet.*;
import java.io.*;
import javax.microedition.io.*;
import java.util.*;
import com.siemens.icm.io.*;
public class One extends MIDlet {
public One() {
}
public void init() throws MIDletStateChangeException {
}
public void startApp() throws MIDletStateChangeException {
doWork();
sendMessage();
notifyDestroyed();
}
public void sendMessage() {
try {
DatagramConnection dgc = null;
dgc = (DatagramConnection)
Connector.open("datagram://192.32.80.192:9001");
String datastring = "such and such work done";
byte[] buf = datastring.getBytes();
Datagram dg = dgc.newDatagram(buf,datastring.length());
//dg.setAddress("datagram://192.32.80.192:9001");
dgc.send(dg);
dgc.close();
}
catch(IllegalArgumentException e3) {
System.out.println(e3);
}
catch(InterruptedIOException e1) {
System.out.println(e1);
}
catch(IOException e) {
System.out.println(e);
}
}
public void pauseApp() {
}
public void destroyApp(boolean cond) {
}
}