I think it was just that your receive buffer was not null terminated. This code works:
Server:
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/serialization/string.hpp>
#include <string>
#include <sstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
using boost::interprocess::message_queue;
using boost::property_tree::ptree; using boost::property_tree::write_json;
#define MAX_SIZE 1000
void send(ptree pt)
{
std::stringstream oss;
write_json(oss,pt);
message_queue mq(boost::interprocess::open_or_create,"coda",10,MAX_SIZE);
mq.send(oss.str().c_str(), oss.str().size(),0);
std::cout << oss.str() << std::endl;
system("PAUSE");
}
int main()
{
ptree pt;
pt.put("prefix","standard");
pt.put("faceID",42);
send(pt);
}
Client:
#include <boost/interprocess/ipc/message_queue.hpp>
#include <string>
#include <strstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/serialization/string.hpp>
using boost::interprocess::message_queue;
using boost::property_tree::ptree;
using boost::property_tree::read_json;
#define MAX_SIZE 1000
int main()
{
message_queue mq (boost::interprocess::open_or_create,"coda",10,MAX_SIZE);
size_t recv_size;
unsigned int priority;
ptree pt;
char buffer[MAX_SIZE];
mq.receive(buffer,MAX_SIZE,recv_size,priority);
buffer[recv_size] = 0;
std::istringstream is(buffer);
read_json(is, pt);
std::cout << "prefix: " << pt.get<std::string>("prefix") << " -- faceID: " << pt.get<std::string>("faceID") << std::endl;
system("PAUSE");
}