Re: Convert byte stream to user defined type/class



Hi,

"Macca" <Macca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AF9FEFD1-5616-407F-BFCB-DF177BA96D02@xxxxxxxxxxxxxxxx
> Hi,
>
> My application receives data from multiple sources transferred over
> ethernet. This data is broken into packets of bytes before being
> transmitted
> over the network.

The package size is (in most cases) irrelevant. The network layer is the
responsible of doing this . your app just read X amount of data.

> My application has to take the data and arrange into a user defined
> type/class.

Serialization could help you here.

> My question is :- what is the best/most efficient way of converting the
> individual packets of bytes into an array of say doubles?

If you know the size of the array you can read that amount of data in a
byte[], then using BitConverter.ToDouble ( .... ) convert each chunk to a
double.




--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


.



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: sendfile(2) SF_NOPUSH flag proposal
    ... > decreases the number of packets. ... > amortized cost or total cost. ... For a small amount of data, ... > But if you turn TCP_NOPUSH on then sendfile() will send the full packets. ...
    (freebsd-arch)
  • 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)
  • Whats the best way to accumulate data?
    ... I have an application that receives data (floats) via a socket. ... Each packet has a header telling me how ... So I create an array with this many elements ... Sometimes the data is split between multiple packets. ...
    (microsoft.public.dotnet.languages.csharp)
  • 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)