.Net 远程处理:反转连接
好吧,这是我第一次使用 .net 远程处理,但到目前为止似乎很有趣。
创建一个公开远程处理对象的服务器,然后从客户端使用它是小菜一碟,并且非常有效。 (顺便说一句,我正在使用 TcpChannel)
我现在想做的是反转连接。 目前,服务器打开一个端口并监听客户端,客户端连接并获取对象的引用并享受它的乐趣。 我唯一想要改变的是客户端将等待连接而不是服务器。 该对象仍应在服务器上创建并从客户端使用。
这对任何人来说都有意义吗? 如果是这样,这可能吗?
Ok so this is the first time I'm playing with .net remoting but seems fun so far.
Creating a server that exposes a remoting object and then consuming it from a client is a piece of cake and works like a charm. (I'm using a TcpChannel btw)
What I wanna do now is reverse the connection.
Currently the server opens a port and listens for the client, the client connects and gets the reference of the object and has fun with it.
The only thing I want changed is that the client will wait for the connection instead of the server.
The object should be still created on the server and used from the client.
Does this make sense to anyone?!
And if so, is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用远程处理时,就术语“服务器”和“客户端”的含义达成一致非常有用。 “服务器”是监听连接的机器。 “客户端”是发起连接的机器。
使用这些定义,您希望客户端启动连接,然后让服务器调用客户端创建的对象上的方法。
所以您想要的是:
MarshalByReferenceObject
,其中包含服务器将调用的方法。尽管如此,我同意您应该使用 WCF 而不是远程处理的评论。
When working with Remoting, it's useful to agree on the meanings of the terms "server" and "client". The "server" is the machine that's listening for connections. The "client" is the machine that initiates the connection.
Using those definitions, you want the client to initiate the connection and then have the server call methods on a client-created object.
So what you want is:
MarshalByReferenceObject
that contains the methods the server will call.All that said, I agree with the comment that says you should use WCF rather than remoting.