I wrote an app on my phone with Android. I'm debugging it on phone. I try to connect to a server written in C#, but every time 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);
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With