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


C# MemBlock.CopyTo方法代码示例

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


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

示例1: HandleIncoming

    override protected bool HandleIncoming(MemBlock data, out MemBlock app_data)
    {
      app_data = null;
      int count = 0;

      lock(_buffer_sync) {
        if(data != null) {
          data.CopyTo(_buffer, 0);
          _read.Write(_buffer, data.Length);
        }

        count = _ssl.Read(_buffer, _buffer.Length);
        if(count > 0) {
          app_data = MemBlock.Copy(_buffer, 0, count);
        }
      }

      if(app_data != null) {
        // If the read was successful, Dtls has received an incoming data
        // message and decrypted it
        return true;
      } else {
        SslError error = _ssl.GetError(count);
        if(error == SslError.SSL_ERROR_WANT_READ) {
          if(SslState == SslState.OK) {
            UpdateState(States.Active);
            // In the SslCtx verify, there's no way to get the underlying Sender
            _ch.Verify(RemoteCertificate, Sender);
          }
          HandleWouldBlock();
        } else if(error == SslError.SSL_ERROR_SSL) {
          var ose = new OpenSslException();
          Close("Received unrecoverable error: " + ose.ToString());
          throw ose;
        } else if(error == SslError.SSL_ERROR_ZERO_RETURN) {
          Close("Received clean close notification");
        } else {
          ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions,
              "Receive other: " + error);
        }
      }
      return false;
    }
开发者ID:pstjuste,项目名称:brunet,代码行数:43,代码来源:DtlsAssociation.cs

示例2: Attribute

 /// <summary>Create a new Attribute.</summary>
 public Attribute(AttributeType type, MemBlock value)
 {
     Type = type;
     Value = value;
     byte[] data = new byte[4 + value.Length];
     NumberSerializer.WriteUShort((ushort) type, data, 0);
     NumberSerializer.WriteUShort((ushort) value.Length, data, 2);
     value.CopyTo(data, 4);
     Data = MemBlock.Reference(data);
 }
开发者ID:reith2004,项目名称:ipop,代码行数:11,代码来源:Stun.cs


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