ExDatagramServer.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- package exframework;
- import javax.microedition.io.DatagramConnection;
- /**
- * <p>Title: ExFramework</p>
- *
- * <p>Description: lizhenpeng</p>
- *
- * <p>Copyright: Copyright (c) 2005</p>
- *
- * <p>Company: LP&P</p>
- *
- * @author lipeng
- * @version 1.0
- */
- import javax.microedition.io.*;
- public class ExDatagramServer implements AllAction
- {
- DatagramConnection conn;
- public ExDatagramServer()
- {
- }
- public void allAction(MainForm form)
- {
- try
- {
- conn=(DatagramConnection)Connector.open("datagram://:8070");
- Datagram dg=conn.newDatagram(1);
- conn.receive(dg);
- byte[] buffer;
- buffer=dg.getData();
- form.addline(dg.getAddress());
- form.addline(String.valueOf(buffer[0]));
- ++buffer[0];
- dg.setData(buffer,0,buffer.length);
- conn.send(dg);
- }
- catch(Exception e)
- {
- System.out.print(e);
- }
- }
- }