sending struct of int from Linux to Windows using boost::asio
Hello All,
I am having trouble using boost:asio to send a simple struct
message_header from server (linux) to the client (windows).
typedef struct MessageHeader
{
uint32_t _data_length; //length of data attached
uint8_t _message_type; //MESSAGE_TYPE
uint8_t _segment_name; //SEGMENT_NAME
uint16_t _request_id; //Request Id assigned by the client
to the request to uniquely identify the request
uint16_t _count_of_records; //Number of records affected by the
operation, 0 means complete segment is affected.
} MessageHeader;
typedef struct Message
{
boost::array
A.Agrawal@patrick.com.au wrote: [snip]
buffers.push_back(boost::asio::buffer((_data_serialized).c_str(), _data_serialized.length()));
[snip] I haven't read all of your code, but I don't think .c_str() will have an object lifetime that exceeds the asynchronous operation. There's support for std::string, you could try buffers.push_back(boost::asio::buffer(_data_serialized)); Have you verified that on your platform sizeof(MessageHeader) equals what you have set for it? Kind regards, Rutger ter Borg
On Thu, 10 Sep 2009 04:50:59 +0200,
Hello All,
I am having trouble using boost:asio to send a simple struct message_header from server (linux) to the client (windows).
Do you deal correctly with the endianness (http://en.wikipedia.org/wiki/Endianness) by using htonl and the like?
Also look at asio+serialization example: http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/examples.html
participants (4)
-
A.Agrawal@patrick.com.au
-
Bjarne Laursen
-
Igor R
-
Rutger ter Borg