zoukankan      html  css  js  c++  java
  • ICE3.4.1试用手记(kenter原创)

    ICE3.4.1试用手记(kenter原创)

    由于项目中服务端用的是C++,客户端是C#。想用一些比较方便而效率也不低的中间件。

    看了下文章介绍ICE http://www.zeroc.com/ice.html

    相关下载 http://www.zeroc.com/download.html

    安装 Ice-3.4.1.msi 后,设置系统变量加入bin目录 以便试用slice命令根据ICE统一接口语言生成相应的文件

    例如我试用VS 2010 配置VC++包含目录,库目录等等

    包含目录加入$(SolutionDir)

    在C/C++项里的“运行时库”为多线程DLL(/MD),否则在编译时会出预编译错误:

    预编译头选“不使用”,并将stdafx.h和stdafx.cpp两个文件去掉,为了兼容性。

    链接器->输入->附加依赖项 加入ice.lib;iceutil.lib;

    下面写个范例,首先创建ICE接口文件

    Printer.ice

    module demo{
      
    interface Printer{
        
    void printString(string s);
      };
    };

     运行CMD使用命令 slice2cpp Printer.ice后

    目录下生成 Printer.h 和 Printer.cpp两个文件

    把这两个文件加入工程

    编写服务端代码

    // TestICEServer.cpp : 定义控制台应用程序的入口点。
    //

    #include 
    <Ice/Ice.h>
    #include 
    <TestICEServer/Printer.h>

    using namespace std;
    using namespace demo;

    class PrinterI : public Printer{
    public:
        
    virtual void printString(const ::std::string& s, 
            
    const ::Ice::Current& /* = ::Ice::Current */);
    };

    void PrinterI::printString(const ::std::string& s, const ::Ice::Current& )
    {
        cout 
    << s << endl;
    }

    int main(int argc, char* argv[])
    {
        
    int status = 0;
        ::Ice::CommunicatorPtr ic;
        
    try{

        }
    catch(const ::Ice::Exception& e){
            cerr 
    << e << endl;
            status 
    = 1;
        }
    catch(const char* msg){
            cerr 
    << msg << endl;
            status 
    = 1;
        }
        
    if (ic)
        {
            
    try
            {
                ic
    ->destroy();
            }
    catch(const ::Ice::Exception& e){
                cerr 
    << e << endl;
                status 
    = 1;
            }
        }
        
    return 0;
    }
  • 相关阅读:
    【计网实验6】静态路由实验
    【计网】第六章
    【操统5】第六章/第七章
    【计网 6】链路层
    【Java学习1】
    【机器学习1】
    【计网实验】packet
    【计网】第五章网络层:控制平面
    python中math模块常用的方法整理
    使用python如何进行截小图
  • 原文地址:https://www.cnblogs.com/kenter/p/2010386.html
Copyright © 2011-2022 走看看