rendered paste body private static boolean connect(String proxy, int port) { boolean working = false; Socket proxySocket = null; PrintWriter out = null; BufferedReader in = null; try { proxySocket = new Socket(proxy, port); out = new PrintWriter(proxySocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader( proxySocket.getInputStream())); out.println("GET http://u1.swirve.com/ HTTP/1.1 \n"); String currentLine; while((currentLine = in.readLine()) != null) { if(currentLine.equals("HTTP/1.1 OK") || currentLine.equals("HTTP/1.0 OK")) { working = true; } } } catch (IOException e) { working = false; } finally { try { out.close(); in.close(); proxySocket.close(); } catch(IOException e) { // log something here? } } return working; }