如何将数据发送到8080端口的本地wifi网络上的Android设备

时间:2014-11-14 18:45:00

标签: android android-networking

这是我如何将数据发送到网络上的另一个Android设备,但它无法正常工作,它会抛出异常

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

        } 

这是Log ..

java.net.ConnectException: failed to connect to  /192.168.0.106 (port 8080) after 1500ms: isConnected failed: ECONNREFUSED (Connection refused)

0 个答案:

没有答案