当前位置:网站首页>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;
}
边栏推荐
- [ecmascript6] other new interface features
- Swiftui layout - size (bottom)
- It's so hot that solar power can't take off? Hello, head
- (function(global,factory){
- Swiftui layout - alignment
- String转为long 类型报错原因:要转为long必须是int、double、float型[通俗易懂]
- Realization of chat room function
- Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
- Redis-Redis在Jedis中的使用
- 35道MySQL面试必问题图解,这样也太好理解了吧
猜你喜欢

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

Various pitfalls encountered in UI development

On July 29, apachecon | apachepulsar's exploration and practice in vivo will be broadcast soon

When Xcode writes swiftui code, it is a small trap that compiles successfully but causes the preview to crash
![[Tanabata] Tanabata lonely little frog research edition? The final chapter of Tanabata Festival!](/img/0b/4fc583a3dd4794b0c2b0d64d905be7.png)
[Tanabata] Tanabata lonely little frog research edition? The final chapter of Tanabata Festival!

Redis-持久化

Redis-配置文件讲解

复制excel行到指定行

如何只降3D相机不降UI相机的分辨率

Brief introduction and use of mqtt entry level
随机推荐
力扣解法汇总1331-数组序号转换
9、 Uni popup usage popup effect at the bottom of the drop-down box
unittest执行runTestCase提示<_io.TextIOWrapper name=‘<stderr>‘ mode=‘w‘ encoding=‘utf-8‘>解决方案
【LeetCode】 贴纸拼词(动态规划)
58 sub station Anju, broker marketing management platform login interface encryption reverse
Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
Bulk Rename Utility
(function(global,factory){
SwiftUI 布局 —— 对齐
为自定义属性包装类型添加类 @Published 的能力
国产数据库的红利还能“吃”多久?
Node file operation
2022年安全员-A证操作证考试题库模拟考试平台操作
Unittest executes runtestcase prompt <_ io. Textiowrapper name= '< stderr>' mode=W encoding=UTF-8 > solution
Cv:: mat conversion to qimage error
数字化转型安全问题频发,山石网科助力数字政府建设
Factory mode and constructor mode
The method of implementing simple student achievement management system with C language
九、uni-popup用法 下拉框底部弹窗效果
Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance