Package org.jboss.netty.buffer

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


            if (msg.readableBytes() < 8) {
                channelFuture.setFailure(new IOException("invalid sock server reply length = " + msg.readableBytes()));
            }
            // ignore
            msg.readByte();
            int status = msg.readByte();
            int port = msg.readShort();
            byte[] addr = new byte[4];
            msg.readBytes(addr);

            ctx.getChannel().setAttachment(new InetSocketAddress(InetAddress.getByAddress(addr), port));
View Full Code Here


        // make sure the entire buffer is still there we started with
        Assert.assertEquals(1, buffer0.readableBytes());

        // another case with an first extra byte
        buffer0 = BufferHelper.createBuffer("39343439353133363139323000");
        buffer0.readByte(); // skip 1 byte
        str0 = ChannelBufferUtil.readNullTerminatedString(buffer0);
        Assert.assertEquals("44951361920", str0);
        // make sure the entire buffer is still there we started with
        Assert.assertEquals(0, buffer0.readableBytes());
View Full Code Here

        // make sure the entire buffer is still there we started with
        Assert.assertEquals(0, buffer0.readableBytes());

        // another case with an first extra byte and last extra byte
        buffer0 = BufferHelper.createBuffer("39343439353133363139323000FF");
        buffer0.readByte(); // skip 1 byte
        str0 = ChannelBufferUtil.readNullTerminatedString(buffer0);
        Assert.assertEquals("44951361920", str0);
        // make sure the entire buffer is still there we started with
        Assert.assertEquals(1, buffer0.readableBytes());
View Full Code Here

        // Discard received data silently by doing nothing.
        transferredBytes.addAndGet(((ChannelBuffer) e.getMessage()).readableBytes());
       
        ChannelBuffer buf = (ChannelBuffer) e.getMessage();
        while(buf.readable()) {
        System.out.println((char) buf.readByte());
        System.out.flush();
        }
    }

    @Override
View Full Code Here

            ChannelBuffer msg = (ChannelBuffer) e.getMessage();
            if (msg.readableBytes() < 8) {
                channelFuture.setFailure(new IOException("invalid sock server reply length = " + msg.readableBytes()));
            }
            // ignore
            msg.readByte();
            int status = msg.readByte();
            int port = msg.readShort();
            byte[] addr = new byte[4];
            msg.readBytes(addr);
View Full Code Here

            if (msg.readableBytes() < 8) {
                channelFuture.setFailure(new IOException("invalid sock server reply length = " + msg.readableBytes()));
            }
            // ignore
            msg.readByte();
            int status = msg.readByte();
            int port = msg.readShort();
            byte[] addr = new byte[4];
            msg.readBytes(addr);

            ctx.getChannel().setAttachment(new InetSocketAddress(InetAddress.getByAddress(addr), port));
View Full Code Here

  @Test
  public void testControlCharacterSkipping() {
    ChannelBuffer buffer = ChannelBuffers.copiedBuffer("  TESTLINE".getBytes());
    IcapDecoderUtil.skipControlCharacters(buffer);
    assertEquals("skipping of whitespaces has not worked",'T',(char)buffer.readByte());
  }
 
  @Test
  public void testSkipControlCharacter() {
    ChannelBuffer buffer = ChannelBuffers.copiedBuffer(new byte[]{0x0001,'A'});
View Full Code Here

 
  @Test
  public void testSkipControlCharacter() {
    ChannelBuffer buffer = ChannelBuffers.copiedBuffer(new byte[]{0x0001,'A'});
    IcapDecoderUtil.skipControlCharacters(buffer);
    assertEquals("control character was not skiped",'A',buffer.readByte());
  }
 
  @Test
  public void testReadLine() {
    StringBuilder builder = new StringBuilder("REQMOD icap://icap.mimo.ch:1344/reqmod ICAP/1.0").append(new String(IcapCodecUtil.CRLF)).append("NEW LINE");
View Full Code Here

                                length = (Integer) getAttribute(ctx, LENGTH_ATTRIBUTE);
                            }
                            while (buffer.readableBytes() > 0) {
                                switch (state) {
                                case WAIT_FOR_FIRST_BYTE_LENGTH:
                                    length = (buffer.readByte() & 255) << 24;
                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                                    break;
                                case WAIT_FOR_SECOND_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 16;
                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
View Full Code Here

                                case WAIT_FOR_FIRST_BYTE_LENGTH:
                                    length = (buffer.readByte() & 255) << 24;
                                    state = State.WAIT_FOR_SECOND_BYTE_LENGTH;
                                    break;
                                case WAIT_FOR_SECOND_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 16;
                                    state = State.WAIT_FOR_THIRD_BYTE_LENGTH;
                                    break;
                                case WAIT_FOR_THIRD_BYTE_LENGTH:
                                    length += (buffer.readByte() & 255) << 8;
                                    state = State.WAIT_FOR_FOURTH_BYTE_LENGTH;
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.