@Override
    public void receivedData(PyroClient client, ByteBuffer data) {
        if (VERBOSE)
            System.out.println("receivedData:" + data.remaining());

        SocksAttachment attachment = client.attachment();

        if (attachment.header != null) {
            // we are still reading the SOCKS4 header...
            if (attachment.target == null) {
                // there is no target found, so feed
                // the data into the header handlers
                attachment.header.feed(data);
            } else {
                // we are connected to somebody else
                // whatever is pending in the header handlers should be
                // retrieved
                ByteBuffer pending = attachment.header.shutdown();

                // stop operating in header mode
                attachment.header = null;

                // handle the pending bytes, if any
                if (pending.hasRemaining())
                    this.receivedData(client, pending);

                // handle the bytes that we just received
                this.receivedData(client, data);
            }
        } else {
            if (VERBOSE) {
                // enqueue data just received to the target it was meant for
                String from = client.getRemoteAddress().getAddress()
                        .getHostAddress();
                String to = attachment.target.getRemoteAddress().getAddress()
                        .getHostAddress();
                System.out.println("   traffic: [" + from + " => " + to + "]");
            }

            attachment.target.writeCopy(data);
        }
    }