how to send data to android device on local wifi network at 8080 port

668 Views Asked by At

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)
0

There are 0 best solutions below