通过udpserver循环接收客户端发来的数据,将所有的数据显示在界面我这边就通过while循环在线程中接收数据,然后通过handler将数据显示在主界面上!可是为什么有时候会卡死!
public class UDPServer implements Runnable {
private byte[] msg = new byte[1024];
private boolean life = true;
private DatagramSocket dSocket = null;
public UDPServer() {
try {
dSocket = new DatagramSocket(17009);
} catch (SocketException e) {
e.printStackTrace();
}
}
/**
* @return the life
*/
public boolean isServer() {
return life;
}
/**
* @param lifes the life to set
*/
public void setServer(boolean lifes) {
this.life = lifes;
LogUtil.e("dSocket.isClosed()show==");
if (life == false && dSocket != null) {