try {
Log.d("test1","start");
flag = true;
portRemoteNum = 2001;
portLocalNum = 8080;
addressIP = "192.168.8.1";
socketUDP = new DatagramSocket(portLocalNum);
} catch (Exception e) {
Log.d("test1",e.getMessage());
e.printStackTrace();
}
try {
InetAddress serverAddress = InetAddress.getByName(addressIP);
byte data[] = str.getBytes();
DatagramPacket packetS = new DatagramPacket(data, data.length,serverAddress,portRemoteNum);
socketUDP.send(packetS);
Log.d("test1","end");
} catch (Exception e) {
Log.d("test1",e.getMessage());
e.printStackTrace();
}
socketUDP.close();
}
这是我想要实现的目标,我有一个设备和一部手机,我可以直接通过wifi连接设备,
Android手机= Wifi =>设备A
然后我使用上面的代码发送udp数据包,它显示" end"但是,在我的日志记录中,我的设备中没有响应,并且没有错误捕获。怎么调试呢?谢谢,问题的根本原因是什么?