linux
运维-linux运维
网址导航网页源码,Ubuntu图片文件压缩,python爬虫数据在,php 字元,岳阳seo外包lzw
linux下ice是什么大秀直播程序源码,ubuntu创建文本,tomcat部署多个端口号,爬虫销售线索,php并发性能高,seo内部博客lzw
ICE是ZEROC的开源通信协议产品,它的全称是:The Internet Communications Engine,翻译为中文是互联网通信引擎,是一个面向对象的中间件,使我们能够以最小的代价构建分布式应用程序。购物直播app源码,vscode如何生成dist,在xp下安装ubuntu,tomcat下载csdn,sqlite _,电脑网站网页设计,window云主机安装mysql数据库,阿里云服务器电信,ectouch支付宝插件,轻量级前端框架难学吗吗,僵硬爬虫,php chm手册,云南seo公司,springboot独有特性,怎么在手机上制作标签页,挂q网站源码,网页文本域代码,小清新模板,如何进入网站后台地址,vb 多页面浏览器源码,个人信息管理系统下载,java闹钟小程序lzw
ICE使我们专注于应用逻辑的开发,它来处理所有底层的网络接口编程,这样我们就不用去考虑这样的细节:打开网络连接、网络数据传输的序列化与反序列化、连接失败的尝试次数等。示例在linux下安装ice过程:
下载安装源
cd /etc/yum.repos.dsudo wget https://zeroc.com/download/Ice/3.7/el7/zeroc-ice3.7.repo
Ice所需库
bzip2 1.0
expat 2.1 or later
LMDB 0.9 (LMDB is not required with the C++11 mapping)
mcpp 2.7.2 with patches
OpenSSL 1.0.0 or later (on AIX and Linux)
安装lmdb-devel mcpp-devel(其他库系统可能自带有,可先不安装,等make报错再安装)
sudo yum install lmdb-devel mcpp-devel
下载Ice源码ice-3.7.3.tar.gz,解压
cd /home/user/tar -zxf ice-3.7.3.tar.gzcd ice-3.7.3/cpp
编译(默认C++98,可设置CXXFLAGS修改为c++11)
sudo make -j4sudo make CXXFLAGS=-std=c++11 -j4
src/Ice/SHA1.cpp:14:31: 致命错误:openssl/sha.h:没有那个文件或目录
sudo yum install openssl-devel
src/Ice/ConnectionI.cpp:27:21: 致命错误:bzlib.h:没有那个文件或目录
sudo yum install bzip2-devel
src/IceXML/Parser.cpp:7:19: 致命错误:expat.h:没有那个文件或目录
sudo yum install expat-devel
安装(默认安装在/opt/Ice-3.7.3)
sudo make install
测试
1)编写ice的slice配置文件
module Demo { interface Printer { void printString(string s); };};
2)编译Slice定义文件(生成Printer.h 和Printer.cpp)找不到slice2cpp,自己配置运行环境在/opt/Ice-3.7.3/bin中
slice2cpp Printer.ice
3)编写服务端,命名为Server.cpp
#include #include using namespace std;using namespace Demo; class PrinterI : public Printer { public: virtual void printString(const string& s, const Ice::Current&);}; void PrinterI::printString(const string& s, const Ice::Current&){ cout << s <createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000"); Ice::ObjectPtr object = new PrinterI; adapter->add(object, ic->stringToIdentity("SimplePrinter")); adapter->activate(); ic->waitForShutdown(); } catch (const Ice::Exception& e) { cerr << e << endl; status = 1; } catch (const char* msg) { cerr << msg <destroy(); } catch (const Ice::Exception& e) { cerr << e << endl; status = 1; } } return status;}
4)编译服务端
c++ -I. -I/opt/Ice-3.7.3/include -c Printer.cpp Server.cppc++ -o server Printer.o Server.o -L/opt/Ice-3.7.3/lib64 -lIce -lpthread
5)编写客户端,命名为Client.cpp
#include #include using namespace std;using namespace Demo; int main(int argc, char* argv[]){ int status = 0; Ice::CommunicatorPtr ic; try { ic = Ice::initialize(argc, argv); Ice::ObjectPrx base = ic->stringToProxy("SimplePrinter:default -p 10000"); PrinterPrx printer = PrinterPrx::checkedCast(base); if (!printer) throw "Invalid proxy"; printer->printString("Hello World!"); } catch (const Ice::Exception& ex) { cerr << ex << endl; status = 1; } catch (const char* msg) { cerr << msg <destroy(); return status;}
6)编译客户端
c++ -I. -I/opt/Ice-3.7.3/include -c Printer.cpp Client.cppc++ -o client Printer.o Client.o -L/opt/Ice-3.7.3/lib64 -lIce -lpthread
7)运行Server,然后运行Client,如果看到输出Hello World!则成功。
《Linux视频教学》