当前位置: 首页>>代码示例>>C#>>正文


C# IByteBuffer.SetWriterIndex方法代码示例

本文整理汇总了C#中IByteBuffer.SetWriterIndex方法的典型用法代码示例。如果您正苦于以下问题:C# IByteBuffer.SetWriterIndex方法的具体用法?C# IByteBuffer.SetWriterIndex怎么用?C# IByteBuffer.SetWriterIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IByteBuffer的用法示例。


在下文中一共展示了IByteBuffer.SetWriterIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyTo

        void CopyTo(int index, int length, int componentId, IByteBuffer dst)
        {
            int dstIndex = 0;
            int i = componentId;

            while (length > 0)
            {
                ComponentEntry c = this.components[i];
                IByteBuffer s = c.Buffer;
                int adjustment = c.Offset;
                int localLength = Math.Min(length, s.Capacity - (index - adjustment));
                s.GetBytes(index - adjustment, dst, dstIndex, localLength);
                index += localLength;
                dstIndex += localLength;
                length -= localLength;
                i++;
            }

            dst.SetWriterIndex(dst.Capacity);
        }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:20,代码来源:CompositeByteBuffer.cs

示例2: ReadBytes

 public virtual IByteBuffer ReadBytes(IByteBuffer destination, int length)
 {
     if (length > destination.WritableBytes)
     {
         throw new IndexOutOfRangeException(string.Format("length({0}) exceeds destination.WritableBytes({1}) where destination is: {2}",
             length, destination.WritableBytes, destination));
     }
     this.ReadBytes(destination, destination.WriterIndex, length);
     destination.SetWriterIndex(destination.WriterIndex + length);
     return this;
 }
开发者ID:dalong123,项目名称:DotNetty,代码行数:11,代码来源:AbstractByteBuffer.cs

示例3: DoReadBytes

        protected override int DoReadBytes(IByteBuffer byteBuf)
        {
            if (!byteBuf.HasArray)
            {
                throw new NotImplementedException("Only IByteBuffer implementations backed by array are supported.");
            }

            SocketError errorCode;
            int received = this.Socket.Receive(byteBuf.Array, byteBuf.ArrayOffset + byteBuf.WriterIndex, byteBuf.WritableBytes, SocketFlags.None, out errorCode);

            switch (errorCode)
            {
                case SocketError.Success:
                    if (received == 0)
                    {
                        return -1; // indicate that socket was closed
                    }
                    break;
                case SocketError.WouldBlock:
                    if (received == 0)
                    {
                        return 0;
                    }
                    break;
                default:
                    throw new SocketException((int)errorCode);
            }

            byteBuf.SetWriterIndex(byteBuf.WriterIndex + received);

            return received;
        }
开发者ID:nayato,项目名称:DotNetty,代码行数:32,代码来源:TcpSocketChannel.cs

示例4: DoReadBytes

        protected override int DoReadBytes(IByteBuffer byteBuf)
        {
            if (!byteBuf.HasArray)
            {
                throw new NotImplementedException("Only IByteBuffer implementations backed by array are supported.");
            }

            SocketError errorCode;
            int received = this.Socket.Receive(byteBuf.Array, byteBuf.ArrayOffset + byteBuf.WriterIndex, byteBuf.WritableBytes, SocketFlags.None, out errorCode);

            if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock)
            {
                throw new SocketException((int)errorCode);
            }

            if (received > 0)
            {
                byteBuf.SetWriterIndex(byteBuf.WriterIndex + received);
            }

            return received;
            //return byteBuf.writeBytes(javaChannel(), byteBuf.writableBytes());
        }
开发者ID:dalong123,项目名称:DotNetty,代码行数:23,代码来源:TcpSocketChannel.cs

示例5: ReadBytes

 public virtual IByteBuffer ReadBytes(IByteBuffer destination, int length)
 {
     if (length > destination.WritableBytes)
     {
         throw new IndexOutOfRangeException($"length({length}) exceeds destination.WritableBytes({destination.WritableBytes}) where destination is: {destination}");
     }
     this.ReadBytes(destination, destination.WriterIndex, length);
     destination.SetWriterIndex(destination.WriterIndex + length);
     return this;
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:10,代码来源:AbstractByteBuffer.cs

示例6: GetBytes

 public virtual IByteBuffer GetBytes(int index, IByteBuffer destination, int length)
 {
     this.GetBytes(index, destination, destination.WriterIndex, length);
     destination.SetWriterIndex(destination.WriterIndex + length);
     return this;
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:6,代码来源:AbstractByteBuffer.cs


注:本文中的IByteBuffer.SetWriterIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。