title: java.net.SocketTimeoutException: Transport endpoint is not connected
body: <p>I'm developing my application on a Samsung Galaxy S which I've upgraded to Android 4.2. The application run normally on this device. </p>
  
  <p>When I test it on a phone which is running Android 2.2, an exception occurs.</p>
  
  <p>I check it again and again，I find that the problem happen after the application sends a UDP  DatagramPacket.</p>
  
  <p>The problem never happen when I comment the code referring to sending UDP DatagramPacket. </p>
  
  <p>Could anyone please tell me what‘s the reason why? How to solve the problem?</p>
  
  <p>Main method：</p>
  
  <pre><code> public static String getDataFromServerInPostMethod(String url,
          String content) {
      HttpURLConnection httpurlconnection = null;
  
      String result = "";
      try {
          InputStream stream = null;
          // String host = android.net.Proxy.getDefaultHost();
          // if (host != null) {
          // int port = android.net.Proxy.getDefaultPort();
          // SocketAddress vAddress = new InetSocketAddress(host, port);
          // java.net.Proxy vProxy = new java.net.Proxy(
          // java.net.Proxy.Type.HTTP, vAddress);
          // httpurlconnection = (HttpURLConnection) new URL(url)
          // .openConnection(vProxy);
          // } else {
          // httpurlconnection = (HttpURLConnection) new URL(url)
          // .openConnection();
          // }
          httpurlconnection = (HttpURLConnection) new URL(url)
                  .openConnection();
          httpurlconnection.setDoOutput(true);
          httpurlconnection.setRequestMethod("POST");
          // httpurlconnection.setRequestProperty("Connection", "Keep-Alive");
          httpurlconnection.setReadTimeout(TIMEOUT * 1000);
          httpurlconnection.setConnectTimeout(TIMEOUT * 1000);
          try {
              httpurlconnection.disconnect();
          } catch (Exception e) {
              e.printStackTrace();
          }
          httpurlconnection.connect();
          MyLog.e(TAG, "getURL:" + httpurlconnection.getURL());
          httpurlconnection.getOutputStream().write(content.getBytes());
          httpurlconnection.getOutputStream().flush();
          httpurlconnection.getOutputStream().close();
          stream = httpurlconnection.getInputStream();
          result = SystemUtil.convertStreamToString(stream);
          if (httpurlconnection.getResponseCode() == 200) {
              MyLog.w(TAG,
                      "Responsed--&gt;&gt;getURL:" + httpurlconnection.getURL());
          } else {
              MyLog.e(TAG,
                      "not Responsed,ResponseCode:"
                              + httpurlconnection.getResponseCode());
          }
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          if (httpurlconnection != null) {
              httpurlconnection.disconnect();
          }
      }
      return result;
  }
  </code></pre>