title: Why does my SOCKS proxy code throw SocketException: Malformed reply from SOCKS server?
body: <p>Why does my SOCKS proxy code throw <code>SocketException: Malformed reply from SOCKS server</code>? I've tried to set in URLConnection or other, but this doesn't work. Only thing that worked - chilkat lib, but it's commercial. So, how I, for example, make http request through a ASOCKS proxy? Maybe exist some free lib for that?</p>
  
  <p>For example, that code:</p>
  
  <pre><code>    SocketAddress addr = new InetSocketAddress(proxy_ip, proxy_port);
      Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr);
      Socket socket = new Socket(proxy);
      InetSocketAddress dest = new InetSocketAddress("google.com", 80);
      try {
          socket.connect(dest);
      } catch (IOException ex) {
          Logger.getLogger(CheckProxy.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  
  <p>Throws exception:</p>
  
  <pre><code>java.net.SocketException: Malformed reply from SOCKS server
  at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
  at java.net.SocksSocketImpl.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at proxychecker.CheckProxy.SocksCheck(CheckProxy.java:86)
  </code></pre>
  
  <p>Where line 86 is "socket.connect(dest);"</p>