no route to host

丶灬走出姿态 提交于 2019-12-23 09:03:48

问题


I wrote apss to mu Phone with Android. I debug it on phone. I try to connection with serwer wrote in C# but every times where I try to connect I have exception

EHOSTUNREACH (No route to host)

I add to manifest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

My code to connect:

try {
        InetAddress serverAddr = InetAddress.getByName(IP);
        int PortI = Integer.parseInt(Port);
        socket = new Socket(serverAddr, PortI);
}

回答1:


Try this!

  1. Check your device is connected with internet which make request to server and on same network when testing in LAN network.

  2. Check you have disabled the firewall of server if you are connected in LAN.

  3. Check the URL where you are sending request.



来源:https://stackoverflow.com/questions/14566698/no-route-to-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!