import java.io.*;

import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HTTPConnectTest extends MIDlet
	implements CommandListener
{
	private Display mDisplay;
	private Command mExitCommand;
	private TextBox mTextBox;

	public HTTPConnectTest()
	{
		mExitCommand = new Command("Exit", Command.EXIT, 0);

		mTextBox = new TextBox("HTTPConnectTest", "", 128, 0);
		mTextBox.addCommand(mExitCommand);
		mTextBox.setCommandListener(this);
	}


	public void commandAction(Command c, Displayable s)
	{
			destroyApp(false);
			notifyDestroyed();
	}

	public void startApp() {
	  mDisplay = Display.getDisplay(this);
	  mDisplay.setCurrent(mTextBox);

	  mTextBox.setString("Server connected, check out the IP in the server log or console");
	  try
	  {
		  HttpConnection hc = (HttpConnection)Connector.open("http://host:port");
		  InputStream in = hc.openInputStream(); // needed for the actual connection to be started
		  in.close();
		  hc.close();
	  }
	  catch (Exception e) 	  { }
  }

  // implementing abstract methods:
  public void pauseApp() {}
  public void destroyApp(boolean unconditional) {}
}