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

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

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.

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. 

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.

My consulting rates are also reasonable.

-----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

The data-structures have __attribute__ ((PACKED)) to prevent word

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.


You can find the EdLUG mailing list FAQ list at:

You can find the EdLUG mailing list FAQ list at:

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