org.apache.mina.common.ByteBuffer.prefixedDataAvailable()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.apache.mina.common.ByteBuffer.prefixedDataAvailable()方法的一些代码示例,展示了ByteBuffer.prefixedDataAvailable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.prefixedDataAvailable()方法的具体详情如下:
包路径:org.apache.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:prefixedDataAvailable

ByteBuffer.prefixedDataAvailable介绍

[英]Returns true if this buffer contains a data which has a data length as a prefix and the buffer has remaining data as enough as specified in the data length field. This method is identical with prefixedDataAvailable( prefixLength, Integer.MAX_VALUE ). Please not that using this method can allow DoS (Denial of Service) attack in case the remote peer sends too big data length value. It is recommended to use #prefixedDataAvailable(int,int)instead.
[中]如果此缓冲区包含以数据长度作为前缀的数据,并且缓冲区中剩余的数据与“数据长度”字段中指定的数据相同,则返回true。此方法与prefixedDataAvailable(PrefixeLength,Integer.MAX_值)相同。请注意,如果远程对等方发送的数据长度值太大,使用此方法可能会允许DoS(拒绝服务)攻击。建议改用#prefixedDataAvailable(int,int)。

代码示例

代码示例来源:origin: org.apache.directory.mina/mina-core

/**
 * Returns <tt>true</tt> if this buffer contains a data which has a data
 * length as a prefix and the buffer has remaining data as enough as
 * specified in the data length field.  This method is identical with
 * <tt>prefixedDataAvailable( prefixLength, Integer.MAX_VALUE )</tt>.
 * Please not that using this method can allow DoS (Denial of Service)
 * attack in case the remote peer sends too big data length value.
 * It is recommended to use {@link #prefixedDataAvailable(int, int)}
 * instead.
 *
 * @param prefixLength the length of the prefix field (1, 2, or 4)
 *
 * @throws IllegalArgumentException if prefixLength is wrong
 * @throws BufferDataException      if data length is negative
 */
public boolean prefixedDataAvailable( int prefixLength )
{
  return prefixedDataAvailable( prefixLength, Integer.MAX_VALUE );
}

代码示例来源:origin: org.apache.directory.mina/mina-core

protected boolean doDecode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out ) throws Exception
  {
    if( !in.prefixedDataAvailable( 4, maxObjectSize ) )
    {
      return false;
    }

    out.write( in.getObject( classLoader ) );
    return true;
  }
}

代码示例来源:origin: org.apache.directory.mina/mina-core

if( !prefixedDataAvailable( prefixLength ) )

代码示例来源:origin: org.apache.directory.mina/mina-core

if( !prefixedDataAvailable( 4 ) )

代码示例来源:origin: org.reddwarfserver.client/sgs-client

if (!msgBuf.prefixedDataAvailable(2)) {
  break;

相关文章