本文整理汇总了C#中MemBlock类的典型用法代码示例。如果您正苦于以下问题:C# MemBlock类的具体用法?C# MemBlock怎么用?C# MemBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemBlock类属于命名空间,在下文中一共展示了MemBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Verify
public static void Verify(MemBlock p, ISender from, object state) {
lock(_class_lock) {
//
// Make sure that the packet equals my state.
//
if (!p.Equals(state)) {
_wrongly_routed++;
}
_received++;
}
}
开发者ID:johnynek,项目名称:brunet,代码行数:11,代码来源:RoutingTester.cs
示例17: HandleData
public void HandleData(MemBlock p, ISender edge, object state)
{
try {
int num = NumberSerializer.ReadInt(p, 0);
Console.WriteLine("Got packet number: {0}", num);
edge.Send( p );
}
catch(Exception x) {
Console.WriteLine("Server got exception on send: {0}", x);
}
}
开发者ID:hseom,项目名称:hseom_brunet,代码行数:11,代码来源:EdgeTester.cs
示例18: HandleReply
public bool HandleReply(ReqrepManager man, ReqrepManager.ReqrepType rt,
int mid,
PType prot,
MemBlock payload,
ISender from,
ReqrepManager.Statistics s,
object state)
{
Console.WriteLine("{0} got our message", from);
return false;
}
开发者ID:johnynek,项目名称:brunet,代码行数:11,代码来源:ReqrepExample.cs
示例19: DirectionalAddress
public DirectionalAddress(MemBlock mb)
{
if (ClassOf(mb) != this.Class) {
throw new System.
ArgumentException
("This is not an AHAddress (Class 124) : ",
this.ToString());
}
_buffer = mb;
_dir = (Direction) NumberSerializer.ReadInt(mb, 0);
}
开发者ID:xujyan,项目名称:brunet,代码行数:11,代码来源:DirectionalAddress.cs
示例20: TextTranslate
/// <summary>
/// This method replaces IP addresses based on some identifier
/// </summary>
/// <param name="payload">Payload to be translated</param>
/// <param name="old_ss_ip">Old source IP address</param>
/// <param name="old_sd_ip">Old destination IP</param>
/// <param name="new_ss_ip">New source IP address</param>
/// <param name="new_sd_ip">New destination IP address</param>
/// <param name="packet_id">A packet identifier</param>
/// <returns>A MemBlock of the translated payload</returns>
public static MemBlock TextTranslate(MemBlock payload, string old_ss_ip,
string old_sd_ip, string new_ss_ip,
string new_sd_ip, string packet_id) {
string sdata = payload.GetString(System.Text.Encoding.UTF8);
if(sdata.Contains(packet_id)) {
sdata = sdata.Replace(old_ss_ip, new_ss_ip);
sdata = sdata.Replace(old_sd_ip, new_sd_ip);
payload = MemBlock.Reference(System.Text.Encoding.UTF8.GetBytes(sdata));
}
return payload;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:21,代码来源:ManagedNodeHelper.cs
注:本文中的MemBlock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论