this.socket.getInputStream().read(response, 0, 8);
InputStream in = this.socket.getInputStream(); in.read(response, 0, 8);
    public Socket connect(String host, int port) throws ProxyConnectionException {        setPrimaryConnectionPort(port);                InetSocketAddress isa = null;                try {            isa = new InetSocketAddress( InetAddress.getByName(host), port );        }catch(IOException ioe) {            throw new ProxyConnectionException(-2, "SOCK4 - IOException: " + ioe.getMessage());        }                InetAddress addr = isa.getAddress();        byte[] hostbytes = addr.getAddress();        byte[] requestPacket = new byte[300];                requestPacket[0] = 4; // means socks4 (field VN)        requestPacket[1] = 1; // means connect (field CD)        requestPacket[2] = new Integer((port & 0xff00) >> 8).byteValue();//(byte) ( (port & 0xff00) >> 8); // (field DSTPORT)        requestPacket[3] = new Integer((port & 0x00ff) ).byteValue(); //(byte) ( port & 0x00ff ); // (field DSTPORT)                // adding the host adress bytes to the packet (field DSTIP)        System.arraycopy(hostbytes, 0, requestPacket, 4, 4);                // adding user id to packet (field USERID)        System.arraycopy(getUser().getBytes(), 0, requestPacket, 8, getUser().length());                // terminate the packet        requestPacket[9 + getUser().length()] = 0;        byte[] response = new byte[8];                // connect the socket        try {            connectToProxy();                        this.socket.getOutputStream().write(requestPacket, 0, 9 + getUser().length());            this.socket.getInputStream().read(response, 0, 8);        }catch(IOException ioe) {            throw new ProxyConnectionException(-2, "SOCK4 - IOException: " + ioe.getMessage());        }                ProxyConnectionException pce;        switch (response[1]) {            case 91:                pce = new ProxyConnectionException(91, "SOCKS4 request rejected or failed");                break;            case 92:                pce = new ProxyConnectionException(92, "SOCKS4 request rejected becasue SOCKS server cannot connect to identd on the client");                break;            case 93:                pce = new ProxyConnectionException(93, "SOCKS4 request rejected because the client program and identd report different user-ids.");                break;            default:                pce = new ProxyConnectionException(-1, "SOCKS4 unknown proxy response");                break;        }                if (pce != null) {            try {                this.socket.close();            }catch(IOException ioe) {}            throw pce;        }                return socket;    }