public Bytes PopAllPackets() { Bytes packet; int sizeOfData; Bytes buffer; if (byteCount <= 0) { DebugStub.WriteLine("UDP PopAllPackets: no data???\n"); DebugStub.Break(); return(null); } using (thisLock.Lock()) { DebugPrint("Popping {0} bytes of data to client\n", byteCount); buffer = new Bytes(new byte[byteCount]); VectorQueueByte incomingPacketQueue = packetContainer.Acquire(); int offset = 0; while ((packet = incomingPacketQueue.ExtractHead()) != null) { VTable.Assert(packet != null); Bitter.Copy(buffer, offset, packet.Length, packet, 0); offset += packet.Length; byteCount -= packet.Length; //delete packet; } packetContainer.Release(incomingPacketQueue); DebugStub.Assert(byteCount == 0); } return(buffer); }