Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.writeShort()


        ChannelBuffer cb = ChannelBuffers.buffer(optLength);
        cb.writeShort(options.size());
        for (Map.Entry<T, Object> entry : options.entrySet())
        {
            T opt = entry.getKey();
            cb.writeShort(opt.getId());
            opt.writeValue(entry.getValue(), cb);
        }
        return cb;
    }
View Full Code Here


        T opt = option.left;
        Object obj = option.right;

        ChannelBuffer cb = ChannelBuffers.buffer(oneSerializedSize(option));

        cb.writeShort(opt.getId());
        opt.writeValue(obj, cb);
        return cb;
    }

    public int oneSerializedSize(Pair<T, Object> option)
View Full Code Here

    {
        int optLength = 2;
        for (Map.Entry<T, Object> entry : options.entrySet())
            optLength += 2 + entry.getKey().serializedValueSize(entry.getValue());
        ChannelBuffer cb = ChannelBuffers.buffer(optLength);
        cb.writeShort(options.size());
        for (Map.Entry<T, Object> entry : options.entrySet())
        {
            T opt = entry.getKey();
            cb.writeShort(opt.getId());
            opt.writeValue(entry.getValue(), cb);
View Full Code Here

        ChannelBuffer cb = ChannelBuffers.buffer(optLength);
        cb.writeShort(options.size());
        for (Map.Entry<T, Object> entry : options.entrySet())
        {
            T opt = entry.getKey();
            cb.writeShort(opt.getId());
            opt.writeValue(entry.getValue(), cb);
        }
        return cb;
    }
View Full Code Here

        }
        byte[] userBytes = System.getProperty("user.name", "").getBytes();
        ChannelBuffer handshake = ChannelBuffers.dynamicBuffer(9 + userBytes.length);
        handshake.writeByte(SOCKS_VERSION_4); // SOCKS version
        handshake.writeByte(CONNECT); // CONNECT
        handshake.writeShort(port); // port
        handshake.writeBytes(address.getAddress()); // remote address to connect to
        handshake.writeBytes(userBytes); // user name
        handshake.writeByte(0x00); // null terminating the string
        return handshake;
    }
View Full Code Here

        byte[] userBytes = System.getProperty("user.name", "").getBytes();
        byte[] hostNameBytes = hostName.getBytes();
        ChannelBuffer handshake = ChannelBuffers.dynamicBuffer(10 + userBytes.length + hostNameBytes.length);
        handshake.writeByte(SOCKS_VERSION_4); // SOCKS version
        handshake.writeByte(CONNECT); // CONNECT
        handshake.writeShort(port); // port
        handshake.writeByte(0x00); // fake ip
        handshake.writeByte(0x00); // fake ip
        handshake.writeByte(0x00); // fake ip
        handshake.writeByte(0x01); // fake ip
        handshake.writeBytes(userBytes); // user name
View Full Code Here

        ChannelBuffer header = ChannelBuffers.buffer(ByteOrder.BIG_ENDIAN, 24);
        header.writeByte((byte)0x81)// magic
        header.writeByte(bcmd.code); // opcode
        short keyLength = (short) (keyBuffer != null ? keyBuffer.capacity() :0);

        header.writeShort(keyLength);
        int extrasLength = extrasBuffer != null ? extrasBuffer.capacity() : 0;
        header.writeByte((byte) extrasLength); // extra length = flags + expiry
        header.writeByte((byte)0); // data type unused
        header.writeShort(responseCode); // status code
View Full Code Here

        header.writeShort(keyLength);
        int extrasLength = extrasBuffer != null ? extrasBuffer.capacity() : 0;
        header.writeByte((byte) extrasLength); // extra length = flags + expiry
        header.writeByte((byte)0); // data type unused
        header.writeShort(responseCode); // status code

        int dataLength = valueBuffer != null ? valueBuffer.capacity() : 0;
        header.writeInt(dataLength + keyLength + extrasLength); // data length
        header.writeInt(opaqueValue); // opaque
View Full Code Here

        case 2:
            if (length >= 65536) {
                throw new IllegalArgumentException(
                        "length does not fit into a short integer: " + length);
            }
            header.writeShort((short) length);
            break;
        case 3:
            if (length >= 16777216) {
                throw new IllegalArgumentException(
                        "length does not fit into a medium integer: " + length);
View Full Code Here

            }
            int headerBlockLength = data.readableBytes();
            int length = (headerBlockLength == 0) ? 12 : 10 + headerBlockLength;
            ChannelBuffer frame = ChannelBuffers.buffer(
                    ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + length);
            frame.writeShort(SPDY_VERSION | 0x8000);
            frame.writeShort(SPDY_SYN_STREAM_FRAME);
            frame.writeByte(flags);
            frame.writeMedium(length);
            frame.writeInt(spdySynStreamFrame.getStreamID());
            frame.writeInt(spdySynStreamFrame.getAssociatedToStreamID());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.