J2ME中文教程 7 开发无线网络应用程序[30]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

 private TextField tf;

 private boolean stop;

 private Command sendCommand = new Command("Send", Command.ITEM, 1);

 private Command exitCommand = new Command("Exit", Command.EXIT, 1);

 InputStream is;

 OutputStream os;

 SocketConnection sc;

 ServerSocketConnection scn;

 Sender sender;

 public Server(SocketMIDlet m) {

  parent = m;

  display = Display.getDisplay(parent);

  f = new Form("Socket Server");

  si = new StringItem("Status:", " ");

  tf = new TextField("Send:", "", 30, TextField.ANY);

  f.append(si);

  f.append(tf);

  f.addCommand(exitCommand);

  f.setCommandListener(this);

  display.setCurrent(f);

 }

 public void start() {

  Thread t = new Thread(this);

  t.start();

 }

 public void run() {

  try {

   si.setText("Waiting for connection");

   scn = (ServerSocketConnection) Connector.open("socket://:5009");

   // Wait for a connection.

本文关键:J2ME中文教程 7 开发无线网络应用程序
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top