Beispiel #1
0
 public Bytes GetBytes(IP.SocketID socketID)
 {
     if (socketID.Protocol == IP.ProtocolFamily.TCP)
     {
         return byteTable.GetOrAdd(socketID, new Bytes(0, 0));
     }
     else //if (socketID.Protocol == IP.ProtocolFamily.UDP)
     {
         if (socketID.LocalEP.Address.GetAddressBytes().Max() > 0)
         {
             Bytes result = byteTable.FirstOrDefault((i) =>
                 i.Key.LocalEP.Address.Equals(socketID.LocalEP.Address) &&
                 i.Key.LocalEP.Port == socketID.LocalEP.Port).Value;
             if (result == null)
                 return new Bytes(0, 0);
             else
                 return result;
         }
         else
         {
             Bytes result = byteTable.FirstOrDefault((i) =>
                 i.Key.LocalEP.AddressFamily ==  socketID.LocalEP.AddressFamily &&
                 i.Key.LocalEP.Port == socketID.LocalEP.Port).Value;
             if (result == null)
                 return new Bytes(0, 0);
             else
                 return result;
         }
     }
 }
Beispiel #2
0
 public NewBytesEventArgs(IP.SocketID socketID)
 {
     SocketID = socketID;
 }