private ReceivePacketBase ReceiveOneAnswer() { if (_socket.Available > 0) { var dataBuffer = new byte[_socket.Available]; _socket.Receive(dataBuffer); ReceivePacketBase packet = PacketFactory.FromByte(dataBuffer); return(packet); } return(null); }
private IDictionary <PhysicalAddress, ReceivePacketBase> ReceiveMultipleAnswers(int datagramLength) { Dictionary <PhysicalAddress, ReceivePacketBase> dict = new Dictionary <PhysicalAddress, ReceivePacketBase>(); if (_socket.Available > 0) { for (int i = 0; i < _socket.Available / datagramLength; i++) { var dataBuffer = new byte[datagramLength]; _socket.Receive(dataBuffer); ReceivePacketBase packet = PacketFactory.FromByte(dataBuffer.ToArray()); dict.Add(packet.Mac, packet); } } return(dict); }