What's the best way to accumulate data?

From: John (johnfofawn_at_hotmail.com)
Date: 04/21/04


Date: 20 Apr 2004 19:35:23 -0700

Hi,

I have an application that receives data (floats) via a socket. My job
is to receive the bytes, byte-swap them and convert them to floats,
and make them available to the application.

The data arrives in packets. Each packet has a header telling me how
many floats will follow. So I create an array with this many elements
and then read them in to the array. There are usually 10,000 to 30,000
samples in each packet.

Sometimes the data is split between multiple packets. I need to
assemble all the data from all the packets into a single array. This
is my question. What's the best way to do this?

Here was my thought: I would still create arrays for each packet. I
would put each packet array into an array list (I don't know how many
packets there will be), then when all the packets are received (a flag
in the header tells me this), I would copy all the arrays into one
super large array (it may have 200,000 floats in it).

Does this seem reasonable? Any other ideas?

This is a real-time system and I receive a packet, or set of packets,
every 200 miliseconds.

Thanks,
John



Relevant Pages

  • Re: UDP Sending an array possible?
    ... Is it possible to send an array instead of a straight line of text? ... i can make a huge string and send it and then ... Is the receiving application a .NET application? ... Sockets break data up into packets, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Aliasing the loopback.
    ... Packets aimed at those addresses will never ever leave your ... But nothing else showing what I vaguely recall .. ... The 8139 has a size two array! ... > model, they are at the data-link level at best, and just pass on what ...
    (comp.os.linux.networking)
  • a question about socket and arrays !
    ... if I copy the array byte after byte using a for loop like ... Question about socket: ... I am going to send packets to the server using lots of threads(one ... or just one socket listening on all coming packets? ...
    (comp.lang.java.help)
  • Re: Convert byte stream to user defined type/class
    ... This data is broken into packets of bytes before being ... The network layer is the ... your app just read X amount of data. ... > individual packets of bytes into an array of say doubles? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Getting a function to return an array
    ... I am trying to write a function which takes several floats as ... then returns 1x6 array of floats. ... The "unsafe" way to have that agreement is ...
    (comp.lang.c)