3

私がやろうとしているのは、アプリケーションAがアプリケーションBに、Aが共有メモリに割り当てたオブジェクトへのポインタを送信させることです( boost::interprocess を使用)。そのポインタ転送には、 を使用するつもりboost::interprocess::message_queueです。offset_ptr明らかに、A からの直接の生ポインタは B では有効ではないため、共有メモリに割り当てられたものを転送しようとします。しかし、それもうまくいかないようです。

プロセス A はこれを行います。

typedef offset_ptr<MyVector> MyVectorPtr;
MyVectorPtr * myvector;    
myvector = segment->construct<MyVectorPtr>( boost::interprocess::anonymous_instance )();

*myvector = segment->construct<MyVector>( boost::interprocess::anonymous_instance )
        (*alloc_inst_vec); ;

// myvector gets filled with data here

//Send on the message queue
mq->send(myvector, sizeof(MyVectorPtr), 0);

プロセス B はこれを行います。

// Create a "buffer" on this side of the queue
MyVectorPtr * myvector; 
myvector = segment->construct<MyVectorPtr>( boost::interprocess::anonymous_instance )();
mq->receive( myvector, sizeof(MyVectorPtr), recvd_size, priority);

私が見ているように、このようにして、プロセスBで彼を無効にするオフセットポインターのビットコピーを行います。これを正しく行うにはどうすればよいですか?

4

2 に答える 2

0

ブーストメーリングリストのこの投稿で説明されているように対処できるようです。

于 2011-01-06T00:34:02.717 に答える