开发者

RCF for two way IPC

开发者 https://www.devze.com 2022-12-19 20:12 出处:网络
I am using RCF for Inter Process Communication in a project. Is there a way in RCF to create a bi directional channel. I will have server and client running in both processes. I was able to get one wa

I am using RCF for Inter Process Communication in a project. Is there a way in RCF to create a bi directional channel. I will have server and client running in both processes. I was able to get one way commmunication working with Win32NamedPipes Here is the server

int main()
{
    MyServiceImpl myServiceImpl;
    RCF::RcfServer server;//(RCF::TcpEndpoint("0.0.0.0", 50001));
    server.addServerTransport(boost::shared_ptr<RCF::I_ServerTransport>(new RCF::Win32NamedPipeServerTransport(("rcfchannel"))));
    server.bind<MyService>(myServiceImpl);
    server.bind<MyService>(myServiceImpl);
    server.start();
    server.waitForStopEvent();

    return 0;
}

Where MyService is the service it is implementing

Client.cpp

int main()
{
    try
    {
        std::vector<std::string> v;
        v.push_back("one");
        v.push_back("two");
        v.push_back("three");

        std::cout << "Before:\n";
        std::copy(
            v.begin(), 
            v.end(), 
            std::ostream_iterator<std::string>(std::cout, "\n"));

        RcfClient<MyService>* m_service = new  RcfClient<MyService>(RCF::Win32NamedPipeEndpoint("rcfchannel"));
        m_service->reverse(v);
        std::cout << "\nAfter:\n";
        std::copy(
            v.begin(), 
            v.end(), 
            std::ostream_iterator<std::string>(std::cout, "\n"));
    }
    catch(const std::exception &e)
    {
        std::cout << "Caught exception:\n";
        std::cout << "Type: " << typeid(e).name() << "\n";
        std::cout << "What: " << e.what() << "\n";
    }

    return 0;
}

Suppose I have another service say "ClientService" running on client side. I开发者_如何学Cs there a way to convert this server to client? I found some convertRCFClienttoSession function in RCF. I didn't find any examples for it.


Does this help?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号