Dear Friends!
I am trying to run networking application in Series 60 MIDP SDK 2.0 Beta Emulator on WTK 2.1
The application connects on real 6600.
My computer has proper internet connection.
Once I run the application on emulator, it asks which connection to use between two: Driect PPP or NT RAS with Null M...
Whatever option I choose, no outbound connection is made.
Here is the MIDlet code:
public class TestMIDlet extends MIDlet
{
private Display display;
private Form form;
private Command retrieve;
public void startApp()
{
display = Display.getDisplay(this);
Form form = new Form("Test MIDlet");
retrieve = new Command("retrieve", Command.OK, 1);
form.addCommand(retrieve);
display.setCurrent(form);
form.setCommandListener(new CommandListener()
{
public void commandAction(Command c, Displayable d)
{
try
{
retrieve();
}
catch (IOException e)
{
((Form)d).append(e.toString());
}
}
} );
}
public void retrieve() throws IOException
{
HttpConnection connection = (HttpConnection)Connector.open("http://199.203.134.51/Test/test");
connection.setRequestMethod("POST");
Writer writer = new OutputStreamWriter(connection.openOutputStream());
writer.write("Test");
writer.flush();
writer.close();
Reader in = new InputStreamReader(connection.openInputStream());
int length = (int)connection.getLength();
char[] chars = new char[length];
in.read(chars);
String text = new String(chars);
form.append(text);
}
}
Thanks.
Baruch.

Reply With Quote

