[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Mar 2004 ]

Re: [edlug] OT: Linux-Windows datastructure exchange C++



On Thu, 2004-03-04 at 09:38, Ed wrote:
> Dear God, where to begin.
> 
> This restates what others have said but it sounds like you are dabbling in things you do not understand. 
> 
> Firstly UDP does not provide a reliable transport mechanism. If packets do not get through you must use application level techniques to detect loss, e.g. sequence numbers. Broadcasting compounds this situation as you also now have no idea whether a packet was received by all intended recipients. Of course there may be good reasons for both choices. But in general if you use UDP and/or broadcasting without application level recovery you are explicitly saying you do not care if packets arrive or not because you have no way of finding out.

Sigh,
I'm really not sure what i said in the OP to make yourself or any-other
suppose UDP was chosen for dubious reasons. Of course we've engineered
systems that are tolerant to packet loss - not that there ever is any on
a tiny 5 PC LAN.


> That said, different machines and compilers may use different conventions for representing binary data, e.g. byte order and alignment but also potentially different bit layout within the bytes. It is also likely that data types may be of different size on different machines. 

Of course... Though the latest Intel CPU appears to support both big and
little endian formats.
In any case our embedded system only (and will only ever) use Intel CPU.

> For this reason it is established practice to convert data to a standard format before transmitting it and to convert it back again on reception (marshalling and unmarshalling). 
> Again, there may be efficiency reason for not doing this but you must define your own bit and byte formats and ensure that each endpoint uses the same convention. From your description it sounds like you need to write a stream of bytes and have the recipient unpack those bytes into data types. My knowledge of C++ is not detailed enough but relying on compiler flags to get packed data beween (presumably) gcc and VC++ strikes me as an interesting way to live your life.
Which there are...

But (Dear God), do you know how to pack indiviual data-structures in
windows ?  ;-)

thanks for good intention as always,
Paul

> My consulting rates are also reasonable.
> 
> Ed
> -----Original Message-----
> From: Paul Redmond <P.Redmond@xxx.xxx.xxx>
> To: EdLUG <edlug@xxx.xxx.xxx>
> Date: Wed, 03 Mar 2004 13:58:03 +0000
> Subject: [edlug] OT: Linux-Windows datastructure exchange C++
> 
> 
> Apologies for the off-topic side to this question.
> 
> Hope someone can help with the following:
> 
> I have a Linux app coded in c++, which sends data-structures to UDP
> broadcast.
> 
> The data-structures have __attribute__ ((PACKED)) to prevent word
> alignment.
> 
> I have a Windows app (C++ VS.NET) to receive these data-structures  but
> i can seem to get the __attribute__ ((PACKED)) to work and consequently
> the data is skewed.
> 
> If anyone has come across this problem before and able to provide a clue
> it would be greatly appreciated.
> 
> Cheers,
> Paul
> 
> -
> ----------------------------------------------------------------------
> You can find the EdLUG mailing list FAQ list at:
> http://www.edlug.org.uk/list_faq.html
> 
> 
> 
> -
> ----------------------------------------------------------------------
> You can find the EdLUG mailing list FAQ list at:
> http://www.edlug.org.uk/list_faq.html

-
----------------------------------------------------------------------
You can find the EdLUG mailing list FAQ list at:
http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble@morpheux.org.DONTSPAMME
homepage