0
我有錯誤的問題「網絡不可達」網絡不可達,而知道的IP和端口
這是錯誤消息我得到
04-01 23:39:06.455: E/ClientActivity(1932): Client Send Error:/192.168.1.25444
04-01 23:39:06.455: W/System.err(1932): java.lang.NullPointerException
04-01 23:39:06.463: W/System.err(1932): at edu.dongthang.controller.AppDelegate$ClientThread.sendMessage(AppDelegate.java:93)
04-01 23:39:06.463: W/System.err(1932): at edu.dongthang.controller.AppDelegate.sendMessage(AppDelegate.java:35)
04-01 23:39:06.463: W/System.err(1932): at edu.dongthang.controller.Controller.sendToAppDel(Controller.java:101)
,當我在錯誤信息
at edu.dongthang.controller.AppDelegate$ClientThread.sendMessage(AppDelegate.java:93)
點擊指向線
if (e.getMessage().equals("Network unreachable"))
的方法
public void sendMessage(String message) throws SocketException{
try {
buf = message.getBytes();
if (buf != null) {
DatagramPacket out = new DatagramPacket(buf, buf.length,
serverAddr, serverPort);
socket.send(out);
network_reachable = true;
}
} catch (Exception e) {
Log.e("ClientActivity", "Client Send Error:" + serverAddr + serverPort);
if (e.getMessage().equals("Network unreachable")) {
Log.e("ClientActivity", "Netork UNREACHABLE!!!!:");
network_reachable = false;
}
closeSocketNoMessge();
}
}
我不知道爲什麼,而我真的有IP 192.168.1.2 =和端口= 5444的話,該消息是「網絡不可達」