public void handshake(PyroClientListener listener) {
            if (SOCKS4.VERBOSE) {
                System.out.println("   request.version=" + this.version);
                System.out.println("   request.command=" + this.command);
                System.out.println("   request.port=" + this.port);
                System.out.println("   request.addr=" + (this.addr[0] & 0xFF)
                        + "." + (this.addr[1] & 0xFF) + "."
                        + (this.addr[2] & 0xFF) + "." + (this.addr[3] & 0xFF));
                System.out.println("   request.userid="
                        + new String(this.userid));
            }

            if (this.version != 4 || this.command != 1) {
                ByteBuffer response = ByteBuffer.allocate(8);
                response.put((byte) 0x00);
                response.put((byte) 0x5b); // rejected
                response.clear();
                src.write(response);
                src.shutdown();
                return;
            }

            try {
                InetAddress iaddr = InetAddress.getByAddress(this.addr);
                // System.out.println("request.host=" + iaddr.getHostName()); //
                // SLOW!
                InetSocketAddress connect = new InetSocketAddress(iaddr,
                        this.port);
                PyroClient dst = src.selector().connect(connect);
                {
                    SocksAttachment srcAtt = src.attachment();
                    srcAtt.target = dst;

                    dst.attach(new SocksAttachment(src));
                }
                dst.addListener(listener);
            } catch (UnknownHostException exc) {
                ByteBuffer response = ByteBuffer.allocate(8);
                response.put((byte) 0x00);
                response.put((byte) 0x5b); // failed
                response.clear();
                src.write(response);
                src.shutdown();
            } catch (IOException exc) {
                ByteBuffer response = ByteBuffer.allocate(8);
                response.put((byte) 0x00);
                response.put((byte) 0x5b); // failed
                response.clear();
                src.write(response);
                src.shutdown();
            }
        }