Fix URLConnectionTest#testConnectTimeouts.

Use StuckServer correctly. When StuckServer isn't
in blocking mode, its local socket address isn't 127.0.0.1.

Attempting to connect to localhost will then throw a
SocketException (ECONNREFUSED) instead of a
SocketTimeoutException.

(cherry picked from commit bf1a9e10eefd28bb3a989df20b4a57c745fb3670)

Bug: 10211309
Change-Id: I8aaab598d043b893e73fab9055082fa420cfb9cd
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
index d39e39f..be549ed 100644
--- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
@@ -1641,9 +1641,12 @@
      * addresses. This is typically one IPv4 address and one IPv6 address.
      */
     public void testConnectTimeouts() throws IOException {
-        StuckServer ss = new StuckServer(false);
+        StuckServer ss = new StuckServer(true);
         int serverPort = ss.getLocalPort();
-        URLConnection urlConnection = new URL("http://localhost:" + serverPort).openConnection();
+        String hostName = ss.getLocalSocketAddress().getAddress().getHostAddress();
+        URLConnection urlConnection = new URL("http://" + hostName + ":" + serverPort + "/")
+                .openConnection();
+
         int timeout = 1000;
         urlConnection.setConnectTimeout(timeout);
         long start = System.currentTimeMillis();