远程过程调用(rpc) [英] Remote Procedure Call(rpc)

查看:177
本文介绍了远程过程调用(rpc)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好,

我正在创建一个我已传递字符串的远程过程调用应用程序
但我仍然无法在客户端和服务器之间传递结构.
请任何人能帮助我...

谢谢,
Kunal Shah

Hi all,

I am creating one application of Remote Procedure Call where i have passed a string
but i am still not able to pass a Structure between client and server.
Please can anyone help me...

Thanks,
Kunal Shah

推荐答案

您可以像传递字符串一样,将结构作为缓冲区传递.但这不是很好,因为服务器和客户端上结构的二进制表示形式可能有所不同. IStream是COM接口,因此在COM级别(高于RPC级别)可用.无论如何,IStream用于序列化,但是您需要编组.

您必须知道,应该在RPC级别定义RPC中使用的一些用户定义的结构.因此,您必须将其封送.这意味着,您将其设置为RPC.在客户端和服务器之间传递结构后,应取消封送并使用它.这意味着,客户端和服务器将始终具有相同的结构,但与自己的平台二进制兼容.这可以手动完成,也可以用于某些RPC编译器,后者会将函数调用转换为RPC调用,并且所有RPC编组例程都将隐藏在代理存根文件中.您将用RPC语言描述您的结构,因此它应该存在于RPC级别.您将使用您的语言处理从RPC级别到您的语言的映射.
如果使用Microsoft RPC,则可能会使用IDL(MIDL)在RPC级别上定义自己的结构.并使用MIDL进行编译.您将在生成的代理和存根文件中拥有所有编组/解组例程.
http://msdn.microsoft.com/zh-CN /library/windows/desktop/aa367080(v=vs.85).aspx [
You can pass your structure just as buffer, exactly like you pass the strings. But it is not very ok, because binary representation of structure may be different on server and client. IStream is COM interface, so it is available at COM level which is higher than RPC level. Anyway, IStream is for serialization, but you need marshalling.

That you have to know, is that some user defined structure used in RPC, should be defined at RPC level. So, you have to marshalize it. It means, you make it RPC. After passing the structure between client and server, it should be unmarshalized and used. This means, clients and servers will have always the same structure, but binary compatible with own platform. This can be done manually, or can be used some RPC compiller, which will convert function calls to RPC calls, and all the RPC marshalling routines will be hidden in proxy stub files. You will describe your structure in the RPC language, so it should exist at RPC level. In your language you will deal with mappings from RPC level to your language.
If you use Microsoft RPC, you would likely to use IDL (MIDL) do define your own structures at RPC level. And use MIDL to compile them. All the marshalling/unmarshalling routines you will have in the generated proxy and stub files.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa367080(v=vs.85).aspx[^]


RPC有很多特色.您可以使用 TAO [ CORBA [ ^ ]规范-下载中包含大量示例.

然后有 DCE RPC [ ^ ]和 ^ ]-您会发现许多示例是
RPC comes in many flavours. You can use TAO[^] which is an excellent implementation of the CORBA[^] specification - and a wide range of examples are included with the download.

Then there is DCE RPC[^], and a variant of DCE RPC is included with Windows[^] - you will find that a number of examples are included with the SDK[^]

Best regards
Espen Harlinn


尝试传递IStream指针
在将结构写入其内容之后:)

另请参见:
使用流对象传输数据 [
Try to pass an IStream pointer
after the writing of the structure into its content :)

See also: Transferring Data with Stream Objects[^]


这篇关于远程过程调用(rpc)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆