this.socket.getOutputStream().write(requestPacket, 0, 10); this.socket.getInputStream().read(response, 0, 10);
out = socket.getOutputStream(); in = socket.getInputStream();  out.write(requestPacket, 0, 10); in.read(response, 0, 10);
    private Socket request(byte[] hostbytes) throws ProxyConnectionException {    	byte[] requestPacket = new byte[1024];    	byte[] response = new byte[10];    	    	requestPacket[0] = 5; // means socks5 (field VN)    	requestPacket[1] = 1; // connect (field CMD)    	requestPacket[2] = 0; // reserved (field RSV)    	requestPacket[3] = 1; // IPv4 (field ATYP)    	        // adding the host adress bytes to the packet (field DST.ADDR)        System.arraycopy(hostbytes, 0, requestPacket, 4, 4);                requestPacket[8] = (byte) ( getPrimaryConnectionPort() >> 8 ); // (field DST.PORT)        requestPacket[9] = (byte) ( getPrimaryConnectionPort() & 0x00ff ); // (field DST.PORT)                try {            this.socket.getOutputStream().write(requestPacket, 0, 10);            this.socket.getInputStream().read(response, 0, 10);        }catch(IOException ioe) {            throw new ProxyConnectionException(-2, "SOCK5 - IOException: " + ioe.getMessage());        }                ProxyConnectionException pce = null;        switch (response[1]) {            case 0:                break; // request successfull            case 1:                pce = new ProxyConnectionException(1, "SOCKS5 general SOCKS server failure");                break;            case 2:                pce = new ProxyConnectionException(2, "SOCKS5 connection not allowed by ruleset");                break;            case 3:                pce = new ProxyConnectionException(3, "SOCKS5 Network unreachable");                break;            case 4:                pce = new ProxyConnectionException(4, "SOCKS5 Host unreachable");                break;            case 5:                pce = new ProxyConnectionException(5, "SOCKS5 Connection refused");                break;            case 6:                pce = new ProxyConnectionException(6, "SOCKS5 TTL expired");                break;            case 7:                pce = new ProxyConnectionException(7, "SOCKS5 Command not supported");                break;            case 8:                pce = new ProxyConnectionException(8, "SOCKS5 Address type not supported");                break;            case 9:                pce = new ProxyConnectionException(9, "SOCKS5 to X'FF' unassigned");                break;            default:                pce = new ProxyConnectionException(-1, "SOCKS5 unknown proxy response");                break;        }                return this.socket;    }