问题
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!
Check your device is connected with internet which make request to server and on same network when testing in LAN network.
Check you have disabled the firewall of server if you are connected in LAN.
Check the URL where you are sending request.
来源:https://stackoverflow.com/questions/14566698/no-route-to-host