Efficient way to copy payload to a byte array

Feb 19, 2011 at 6:12 PM

for copying a payload data to a byte array, I m using the following code


byte[] qas = new byte[udp.Payload.Length];
for (int i = 0; i < udp.Payload.Length; i++)
   qas[i] = udp.Payload[i];


Is there any other efficient way for doing this.



Feb 20, 2011 at 5:20 PM

this looks fine , why do you want to change it ??

Feb 21, 2011 at 2:19 AM

Is there a memory copy operation which would be quicker ? Or is the fo rloop for such small data just as quick ?

Just thinking of capture/resend at high rates  (ie. 24Mb/s++)

Feb 22, 2011 at 3:03 PM


I think this code is not so efficient for parsing payload of every packet during live packet capture. This code is open for critics

Feb 23, 2011 at 6:47 AM

have the piece of code for efficient code this?

Feb 26, 2011 at 7:50 AM

I suggest using ToMemoryStream() on the Datagram and then reading from that MemoryStream efficiently.