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


C# MemBlock类代码示例

本文整理汇总了C#中MemBlock的典型用法代码示例。如果您正苦于以下问题:C# MemBlock类的具体用法?C# MemBlock怎么用?C# MemBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: UdpPacket

 /**
 <summary>Takes in a MemBlock and parses it as a Udp Packet.</summary>
 <param name="packet">The MemBlock containing the Udp Packet</param>
  */
 public UdpPacket(MemBlock packet)
 {
     _icpacket = _packet = packet;
       SourcePort = (packet[0] << 8) | packet[1];
       DestinationPort = (packet[2] << 8) | packet[3];
       _icpayload = _payload = packet.Slice(8);
 }
开发者ID:reith2004,项目名称:ipop,代码行数:11,代码来源:Udp.cs

示例2: HandleData

    public void HandleData(MemBlock packet, ISender from, object node)
    {
      _message_count++;

      long stop_time, rt_ticks = -10000;

      if ( !from.Equals(node)) {
        if (packet[0] == 0) {
        //log.Debug("Echo Response:");
	  stop_time = System.DateTime.Now.Ticks;
	  int received_uid = NumberSerializer.ReadInt(packet, 1);
          if(uid_starttime.ContainsKey(received_uid)){
		rt_ticks = stop_time - (long)EchoTester.uid_starttime[received_uid];
	  }
	  double rt_ms = (double) rt_ticks/10000.0;
	  uid_brunetpingtime.Add(received_uid, rt_ms);
	  Console.WriteLine("Packet ID = {0}, Round-trip = {1}", received_uid, rt_ms); 	  
        }
        else {
        //log.Debug("Echo Request:");
        }

        //log.Debug(packet.ToString());

        //System.Console.WriteLine("{0}", packet.ToString());

        if (packet[0] > 0) {
          //Send a reply back, this is a request  
	  byte[] new_payload = new byte[ packet.Length ];
	  packet.CopyTo(new_payload, 0);
          new_payload[0] = (byte) 0;
          from.Send(new CopyList(PType.Protocol.Echo, MemBlock.Reference(new_payload)));
        }
      }
    }
开发者ID:hseom,项目名称:hseom_brunet,代码行数:35,代码来源:EchoTester.cs

示例3: EthernetPacket

 /// <summary>This parses a MemBlock into the Ethernet fields</summary>
 ///  <param name="Packet">The Ethernet packet</param>
 public EthernetPacket(MemBlock Packet) {
   _icpacket = _packet = Packet;
   DestinationAddress = Packet.Slice(0, 6);
   SourceAddress = Packet.Slice(6, 6);
   Type = (Types) ((Packet[12] << 8) | Packet[13]);
   _icpayload = _payload = Packet.Slice(14);
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:9,代码来源:Ethernet.cs

示例4: IgmpPacket

 public IgmpPacket(MemBlock packet)
 {
     _icpacket = _packet = packet;
       Type = packet[0];
       GroupAddress = packet.Slice(4, 4);
       _icpayload = _payload = packet.Slice(8);
 }
开发者ID:reith2004,项目名称:ipop,代码行数:7,代码来源:Igmp.cs

示例5: HandleData

 public void HandleData(MemBlock payload, ISender return_path, object state) {
   if(_sub != null) {
     MemBlock rest = null;
     PType.Parse(payload, out rest);
     _sub.Handle(rest, return_path);
   }
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:7,代码来源:RoutingDataHandler.cs

示例6: SecurityControlMessage

 static SecurityControlMessage()
 {
   byte[] empty_cookie = new byte[CookieLength];
   for(int i = 0; i < CookieLength; i++) {
     empty_cookie[i] = 0;
   }
   EmptyCookie = MemBlock.Reference(empty_cookie);
 }
开发者ID:hseom,项目名称:brunet,代码行数:8,代码来源:SecurityControlMessage.cs

示例7: DhtDns

 /**
 <summary>Create a DhtDns using the specified Dht object</summary>
 <param name="dht">A Dht object used to acquire name translations</param>
 */
 public DhtDns(MemBlock ip, MemBlock netmask, string name_server,
     bool forward_queries, IDht dht, String ipop_namespace) :
   base(ip, netmask, name_server, forward_queries)
 {
   _ipop_namespace = ipop_namespace;
   _dht = dht;
   _sync = new object();
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:12,代码来源:DhtDns.cs

示例8: HandleData

 public void HandleData(MemBlock payload, ISender return_path, object state) {
   _last_received = payload;
   _ht[payload] = return_path;
   _order.Add(payload);
   if(HandleDataCallback != null) {
     HandleDataCallback(payload, null);
   }
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:8,代码来源:MockDataHandler.cs

示例9: HandleData

 public void HandleData(MemBlock b, ISender return_path, object state) {
   byte b0 = b[0];
   if( b0 == 0 ) {
     //This is a request:
     MemBlock data = b.Slice(1);
     //Make sure node to reply with a zero
     return_path.Send( new CopyList( PType.Protocol.Echo, REPLY_HEADER, data) );
   }
 }
开发者ID:xujyan,项目名称:brunet,代码行数:9,代码来源:EchoHandler.cs

示例10: UdpPacket

 /**
 <summary>Takes in a MemBlock and parses it as a Udp Packet.</summary>
 <param name="packet">The MemBlock containing the Udp Packet</param>
  */
 public UdpPacket(MemBlock packet) {
   if(packet.Length < 8) {
     throw new Exception("Invalid UDP Packet");
   }
   _icpacket = _packet = packet;
   SourcePort = (packet[0] << 8) | packet[1];
   DestinationPort = (packet[2] << 8) | packet[3];
   _icpayload = _payload = packet.Slice(8);
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:13,代码来源:Udp.cs

示例11: AHHeader

 /** Parse the first LENGTH bytes to get the AHHeader
  */
 public AHHeader(MemBlock mb) {
   Hops = NumberSerializer.ReadShort(mb, 0);
   Ttl = NumberSerializer.ReadShort(mb, 2);
   //We parse the Address objects lazily
   Opts = (ushort)NumberSerializer.ReadShort(mb, 2 * Address.MemSize + 4);
   if( mb.Length != LENGTH ) {
     mb = mb.Slice(0,LENGTH);
   }
   _data = mb;
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:12,代码来源:AHSender.cs

示例12: Resolve

 /// <summary>Translates an IP Address to a Brunet Address.  If it is in the
 /// cache it returns a result, otherwise it returns null and begins a Miss
 /// lookup.</summary>
 /// <param name="ip">The IP Address to translate.</param>
 /// <returns>Null if none exists or there is a miss or the Brunet Address if
 /// one exists in the cache</returns>
 public Address Resolve(MemBlock ip)
 {
   Address addr;
   bool update;
   bool success = _cache.TryGetValue(ip, out addr, out update);
   if(update || !success) {
     Miss(ip);
   }
   return addr;
 }
开发者ID:hseom,项目名称:brunet,代码行数:16,代码来源:DhtAddressResolver.cs

示例13: HandleData

 public void HandleData(MemBlock data, ISender return_path, object state)
 {
   /*
    * Write the messages:
    */
   Console.WriteLine("Msg from: {0}", return_path);
   data.ToMemoryStream().WriteTo( System.Console.OpenStandardOutput() );
   Console.WriteLine();
   return_path.Send( new CopyList(PType.Protocol.Chat, MemBlock.Null) );
 }
开发者ID:johnynek,项目名称:brunet,代码行数:10,代码来源:ReqrepExample.cs

示例14: DataPacket

    public DataPacket(ICopyable packet) {
      _update_icpacket = false;
      _update_packet = false;

      _icpacket = packet;
      _packet = packet as MemBlock;
      if(_packet == null) {
        _update_packet = true;
      }
    }
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:10,代码来源:DataPacket.cs

示例15: Free

    /// <summary>
    /// 释放
    /// </summary>
    /// <param name="block"></param>
    public void Free(MemBlock block)
    {
        if (block.GetBytes() == null)
            return;

        int nIndex = GetIndex(block.GetMaxLength());
        if (nIndex >= mMaxList)
            return;

        mAllMemList[nIndex].Enqueue(block);
    }
开发者ID:ZhuangChun,项目名称:GodLightEngine,代码行数:15,代码来源:MemPoolNoLock.cs


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