This is how I m sending data to another android device on the network but it is not working it is throwing exception
try {
HttpURLConnection urlc = (HttpURLConnection) (new URL("http://192.168.0.106:8080/?data=123").openConnection());
urlc.setRequestProperty("User-Agent", "Test");
urlc.setRequestProperty("Connection", "close");
urlc.setConnectTimeout(500);
urlc.connect();
InputStream in = new BufferedInputStream(urlc.getInputStream());
Log.d("Ping Response",urlc.getResponseCode()+"-");
if(urlc.getResponseCode() == 200){
}else {
}
} catch (Exception e) {
Log.d("ActivityDiscovery", "Sending command to player", e);
}
Here is the Log..
java.net.ConnectException: failed to connect to /192.168.0.106 (port 8080) after 1500ms: isConnected failed: ECONNREFUSED (Connection refused)