this.socket.getOutputStream().write(requestPacket, 0, 9 + getUser().length()); this.socket.getInputStream().read(response, 0, 8);
out = socket.getOutputStream(); in = socket.getInputStream();  out.write(requestPacket, 0, 9 + getUser().getBytes().length); in.read(response, 0, 8);
    public Socket bind(InetSocketAddress isa) throws IOException {                InetAddress addr = isa.getAddress();        byte[] hostbytes = addr.getAddress();        byte[] requestPacket = new byte[300];                requestPacket[0] = 4; // means socks4 (field VN)        requestPacket[1] = 2; // means bind (field CD)        requestPacket[2] = (byte) ( getPrimaryConnectionPort() >> 8 ); // (field DSTPORT)        requestPacket[3] = (byte) ( getPrimaryConnectionPort() & 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 = null;        switch (response[1]) {            case 90:                break; // bind successfull            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;        }             int bindPort = ((int) response[2]) & ((int) response[3]);        byte[] bindAddr = { response[4] ,response[5], response[6], response[7] };        InetAddress inetAddress = InetAddress.getByAddress(bindAddr);                log.debug("Binding to: " + inetAddress.getHostAddress() + ":" + bindPort);                return this.socket;    }