是这样的private void connection(){
try {
mSend =new Socket("192.168.33.66", 8888);
toastText("链接成功");
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
toastText("连接失败"+e.getMessage());
Log.e("ssss",e.getMessage());
} catch (IOException e) {
// TODO Auto-generated catch block
toastText("连接失败"+e.getMessage());
Log.e("assss",e.getMessage());
}
}
打印出来的是:ailed to connect to /192.168.33.66 (port 8888): connect failed: ENETUNREACH (Network is unreachable)

解决方案 »

  1.   


    ip地址我是看的电脑上当前的ip,端口我也换过的,应该不是端口的问题吧
      

  2.   

    把手机的网关了,只开wifi,把PC上的防火墙关闭了
      

  3.   

    手机飞行模式打开WIFI,PC关闭360等防火墙。
      

  4.   


    是IP的问题,android默认PC的ip 是:10.0.2.2,
      

  5.   


    应该不是ip的问题,如果服务器不是当前pc,就只能根据ip找到机子
      

  6.   

    哥们这问题解决没 ,我这里也是同样的异常!!
    String url = "http://192.168.0.XXX:8080/imageservice/NewServlet";
    try{
    URL path = new URL(url);
    HttpURLConnection con = (HttpURLConnection) path.openConnection();
    // 判断是否连接真确
    if (con.getResponseCode() == 200) { InputStream input = con.getInputStream();
    return xmlParse(input);
    }else{
    System.out.println("yyyyyyyyyyyyyyyyy");
    }
    }catch(Exception e){
    e.printStackTrace();