当前位置:网站首页>RPC (remote procedure call protocol) telecommunication framework
RPC (remote procedure call protocol) telecommunication framework
2022-07-28 14:51:00 【Love the west wind】
One 、 brief introduction
Official website :Remote Call Framework (RCF) - Delta V Software
Download version :RCF 3.2.403 ubuntu 20
https://www.deltavsoft.com/downloads/RCF-3.2.413.tar.gz
RCF(Remote Call Framework, Remote call framework ) It's a C++ Framework . This framework is used to implement C++ Program interprocess calls provide a simple and consistent (consistent) Methods . This framework is based on strongly typed C/S Interface concept , Similar to what users are familiar with CORBA,DCOM Such middleware .
Be careful : Only support C++
Two 、RCF advantage :
· Portability Supports multiple compilers , And operating systems .
· Scalability It can be used in a wide range of applications , From parent-child process IPC To large distributed systems .
· Efficient , Zero copy is used on some critical paths , Zero distribution , Including server and client .
· Support multiple transmission modes (TCP, UDP, Win32 Famous pipeline and UNIX Local socket ).
· Support for compression and encryption .
· Support one-way and two-way messages .
· Support batch one-way messages .
· Support Publishing / Subscribe to style messages .
· Support UDP Multicast and broadcasting on .
· Support callback from server to client .
· Robust version support .
· Built in serialization framework .
· The built-in Boost.Serialization Support .
· The built-in Google's Protocol Buffers Support .
· Support single thread and multi thread programming modes .
· Without relying on , Except for some Boost The header file (1.33.0 or later). zlib and OpenSSL Dependency is optional .
3、 ... and 、RCF Use scenarios
· client - Server system , Distributed in LAN or WAN . From the perspective of industrial process control , Replace distributed desktop applications DCOM, Provide cross platform communication capability .
Background service component , In a typical homogeneous LAN environment .
· Windows Communication between the service and her monitoring program .
· 32 Bit and 64 Bit executable component communication bridge , for example 64 Bit program call 32 Bit dynamic link library .
· Communication between parent and child processes .
· General local IPC, replace COM.
Four 、linux ubuntu compile
Remote Call Framework (RCF) - Delta V Software
https://www.deltavsoft.com/doc/_building_r_c_f.html
RCF-3.2.413/src/RCF/Uuid.cpp:46:10: fatal error: uuid/uuid.h: There is no file or directory
This is because... Is not installed uuid Caused by the software package ,ubuntu Commands can be used under the system sudo apt-get install uuid-dev install .
5、 ... and 、 Use
TCP Server and Client
#include <iostream>
#include <RCF/RCF.hpp>
// Define the I_PrintService RCF interface.
RCF_BEGIN(I_PrintService, "I_PrintService")
RCF_METHOD_V1(void, Print, const std::string &)
RCF_END(I_PrintService)
// Server implementation of the I_PrintService RCF interface.
class PrintService
{
public:
void Print(const std::string & s)
{
std::cout << "I_PrintService service: " << s << std::endl;
}
};
int main()
{
try
{
// Initialize RCF.
RCF::RcfInit rcfInit;
// Instantiate a RCF server.
RCF::RcfServer server(RCF::TcpEndpoint("127.0.0.1", 50001));
// Bind the I_PrintService interface.
PrintService printService;
server.bind<I_PrintService>(printService);
// Start the server.
server.start();
std::cout << "Press Enter to exit..." << std::endl;
std::cin.get();
}
catch ( const RCF::Exception & e )
{
std::cout << "Error: " << e.getErrorMessage() << std::endl;
}
return 0;
}TCP Client
#include <iostream>
#include <RCF/RCF.hpp>
// Define the I_PrintService RCF interface.
RCF_BEGIN(I_PrintService, "I_PrintService")
RCF_METHOD_V1(void, Print, const std::string &)
RCF_END(I_PrintService)
int main()
{
try
{
// Initialize RCF.
RCF::RcfInit rcfInit;
std::cout << "Calling the I_PrintService Print() method." << std::endl;
// Instantiate a RCF client.
RcfClient<I_PrintService> client(RCF::TcpEndpoint("127.0.0.1", 50001));
// Connect to the server and call the Print() method.
client.Print("Hello World");
}
catch ( const RCF::Exception & e )
{
std::cout << "Error: " << e.getErrorMessage() << std::endl;
}
return 0;
}
6、 ... and 、 Support subscription 、 How to publish
Publish/subscribe - Publisher
#include <iostream>
#include <RCF/RCF.hpp>
// Define RCF interface.
RCF_BEGIN(I_PrintService, "I_PrintService")
RCF_METHOD_V1(void, Print, const std::string &)
RCF_END(I_PrintService)
int main()
{
try
{
RCF::RcfInit rcfInit;
RCF::RcfServer server(RCF::TcpEndpoint("127.0.0.1", 50001));
server.start();
// Configure a publisher.
typedef RCF::Publisher<I_PrintService> PrintServicePublisher;
typedef std::shared_ptr< PrintServicePublisher > PrintServicePublisherPtr;
PrintServicePublisherPtr publisherPtr = server.createPublisher<I_PrintService>();
// Publish a message once every second.
while ( true )
{
publisherPtr->publish().Print("Hello World");
RCF::sleepMs(1000);
}
}
catch ( const RCF::Exception & e )
{
std::cout << "Error: " << e.getErrorMessage() << std::endl;
}
return 0;
}
Publish/subscribe - Subscriber
#include <iostream>
#include <RCF/RCF.hpp>
// Define RCF interface.
RCF_BEGIN(I_PrintService, "I_PrintService")
RCF_METHOD_V1(void, Print, const std::string &)
RCF_END(I_PrintService)
// This class will receive the published messages.
class PrintService
{
public:
void Print(const std::string & s)
{
std::cout << "I_PrintService service: " << s << std::endl;
}
};
int main()
{
try
{
RCF::RcfInit rcfInit;
PrintService printService;
RCF::RcfServer server(RCF::TcpEndpoint(-1));
server.start();
// Configure a subscription.
RCF::SubscriptionParms subParms;
subParms.setPublisherEndpoint(RCF::TcpEndpoint("127.0.0.1", 50001));
RCF::SubscriptionPtr subscriptionPtr = server.createSubscription<I_PrintService>(
printService,
subParms);
// At this point, should be receiving published messages from the publisher.
// ...
std::cout << "Press Enter to exit..." << std::endl;
std::cin.get();
}
catch ( const RCF::Exception & e )
{
std::cout << "Error: " << e.getErrorMessage() << std::endl;
}
return 0;
}
边栏推荐
- pix2pix
- 爆肝整理JVM十大模块知识点总结,不信你还不懂
- C # read INI file and key value pair operation
- 2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination
- How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
- C # 7 methods to obtain the current path
- Bulk Rename Utility
- 2022年熔化焊接与热切割考题及在线模拟考试
- The method of implementing simple student achievement management system with C language
- C语言中浮点数据类型(你学废了吗)
猜你喜欢

Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it

linux安装redis

多商户商城系统功能拆解17讲-平台端订单列表

Redis persistence

Many "double first-class" universities have launched the research guarantee and prediction name!

2022 melting welding and thermal cutting examination questions and online simulation examination

数字化转型安全问题频发,山石网科助力数字政府建设

Langjing Technology (Trax China) "robot +ai" opens the era of Chinese retail meta universe

围绕新市民金融聚焦差异化产品设计、智能技术提效及素养教育

@DS('slave') 多数据源兼容事务问题解决方案
随机推荐
How to perform batch operations in core data
如何在 Core Data 中进行批量操作
为自定义属性包装类型添加类 @Published 的能力
Excel VBA 免密查看VBE加密代码
1st pre class exercise
[ecmascript6] other new interface features
Brief introduction and use of mqtt entry level
C language: mathematical method of converting decimal system into binary system
[ecmascript6] async and await
Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?
力扣解法汇总1331-数组序号转换
面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?
Chi square distribution and gamma function
Hcip day 10
Hcip day 12
Getting started with scottplot tutorial: getting and displaying values at the mouse
Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
围绕新市民金融聚焦差异化产品设计、智能技术提效及素养教育
SwiftUI 布局 —— 对齐
企鹅一面:为什么不建议使用SELECT * ?