C++ RPC 教程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1585012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:31:50  来源:igfitidea点击:

C++ RPC tutorial?

c++visual-c++visual-studio-2008rpc

提问by George2

I want to learn programming C++ (native) on Windows platform for RPC communication. I want to learn both server and client side. I also want to learn some advanced topics, like performance and security.

我想在 Windows 平台上学习编程 C++(本机)以进行 RPC 通信。我想学习服务器端和客户端。我还想学习一些高级主题,例如性能和安全性。

Any good recommended materials to read?

有什么好的推荐阅读材料吗?

(BTW: I Googled a few, but all of them either too brief or COM related, I want to learn pure RPC programming without COM. I am using VSTS 2008 with C++.)

(顺便说一句:我在谷歌上搜索了一些,但它们要么太简短,要么与 COM 相关,我想学习没有 COM 的纯 RPC 编程。我正在使用 VSTS 2008 和 C++。)

采纳答案by slashmais

Try this:

尝试这个:

Overview

概述

Technical Reference- also describes what it is & how it works

技术参考- 还描述了它是什么以及它是如何工作的

回答by Shay Erlichmen

I would start with the Platform SDK samples on RPC.

我将从RPC 上Platform SDK 示例开始

  • ASYNCRPCillustrates the structure of an RPC application that uses asynchronous remote procedure calls. It also demonstrates various methods of notification of the call's completion.
  • CLUUIDdemonstrates use of the client-object UUID to enable a client to select from multiple implementations of a remote procedure.
  • DATAdirectory contains four programs:
    • DUNIONillustrates discriminated (nonencapsulated) unions;
    • INOUTdemonstrates [in], [out] parameters;
    • REPASdemonstrates the represent_as attribute;
    • XMITdemonstrates the transmit_as attribute.
  • DYNEPTdemonstrates a client application managing its connection to the server through dynamic endpoints.
  • FILEREPdirectory contains four samples illustrating how developers can write a simple file replication service, a multi-user file replication service, a service supporting security features, and a service using RPC asynchronous pipes.
  • HANDLESdirectory contains three programs, AUTO, CXHNDL, USRDEF, which demonstrate auto_handle, [context_handle], and generic (user-defined) handles, respectively.
  • HELLOis a client/server implementation of "Hello, world."
  • PICKLEdirectory contains two programs:
    • PICKLPdemonstrates data procedure serialization;
    • PICKLTdemonstrates data type serialization; both programs use the [encode] and [decode] attributes.
  • PIPESdemonstrates the use of the pipe-type constructor.
  • RPCSVCdemonstrates the implementation of a service with RPC.
  • STROUTdemonstrates how to allocate memory at a server for a two-dimensional object (an array of pointers) and pass it back to the client as an [out]-only parameter. The client then frees the memory. This technique allows the stub to call the server without knowing in advance how much data will be returned.
  • ASYNCRPC说明了使用异步远程过程调用的 RPC 应用程序的结构。它还演示了各种通知呼叫完成的方法。
  • CLUUID演示了使用客户端对象 UUID 使客户端能够从远程过程的多个实现中进行选择。
  • DATA目录包含四个程序:
    • DUNION说明了有区别的(非封装的)联合;
    • INOUT演示 [in]、[out] 参数;
    • REPAS演示了represent_as 属性;
    • XMIT演示了transmit_as 属性。
  • DYNEPT演示了一个客户端应用程序通过动态端点管理其与服务器的连接。
  • FILEREP目录包含四个示例,说明开发人员如何编写简单的文件复制服务、多用户文件复制服务、支持安全功能的服务和使用 RPC 异步管道的服务。
  • 手柄目录包含三个程序,AUTO,CXHNDL,USRDEF,它们分别表明auto_handle,[的context_handle],和通用(用户定义的)把手,。
  • HELLO是“Hello, world”的客户端/服务器实现。
  • PICKLE目录包含两个程序:
    • PICKLP演示数据过程序列化;
    • PICKLT演示了数据类型序列化;两个程序都使用 [encode] 和 [decode] 属性。
  • PIPES演示了管道类型构造函数的使用。
  • RPCCSVC演示了使用 RPC 实现服务。
  • STROUT演示了如何在服务器上为二维对象(指针数组)分配内存并将其作为 [out]-only 参数传递回客户端。然后客户端释放内存。这种技术允许存根调用服务器而无需事先知道将返回多少数据。

回答by geva30

why do you want to learn "raw" RPC? there are many good higher level RPC implementations:

为什么要学习“原始”RPC?有许多很好的更高级别的 RPC 实现:

  1. CORBA implementations
  2. google's protocol buffers
  3. Thrift
  1. CORBA 实现
  2. 谷歌的协议缓冲区
  3. 节约

回答by dirkgently

You need to learn 3 different things probably:

您可能需要学习 3 种不同的东西:

  • The C++ programming language
  • RPC
  • Some C++ RPC library
  • C++ 编程语言
  • RPC
  • 一些 C++ RPC 库

回答by dicroce

RPC == "Remote Procedure Call"

RPC ==“远程过程调用”

Essentially, its the idea that communications between two endpoints is best modeled on the concept of those endpoints making logical function calls on each other. In general one side "publishes" an API in some way (for example, if your using SOAP, typically you'll have a file called a WSDL (pronounced wizdel) that enumerates the functions you respond to... a client will first download your WSDL and then make calls to your available API's)... These days, almost all of the available technologies will layer their specific protocols on top of HTTP (for example Web Services, UPnP, REST).. This generally means you're servers are implemented on top of web servers...

本质上,它的想法是,两个端点之间的通信最好以这些端点相互进行逻辑函数调用的概念为模型。一般来说,一方以某种方式“发布”一个 API(例如,如果您使用 SOAP,通常您将拥有一个名为 WSDL(发音为 wizdel)的文件,该文件枚举您响应的函数......客户端将首先下载您的 WSDL,然后调用您可用的 API)...如今,几乎所有可用的技术都将其特定协议分层在 HTTP 之上(例如 Web 服务、UPnP、REST)。这通常意味着您服务器是在 Web 服务器之上实现的...

So, if all you need to implement is the client side, then you can probably use libcurl for all of your HTTP needs...

因此,如果您需要实现的只是客户端,那么您可能可以使用 libcurl 来满足您的所有 HTTP 需求......

回答by Jean Davy

Have a look to RCF, Deltavsoft_Linkand CodeProject_Link

看看 RCF、 Deltavsoft_LinkCodeProject_Link

Main behavior is that RCF doesn't use a separate IDL (Interface Definition Language).

主要行为是 RCF 不使用单独的 IDL(接口定义语言)。