使用 C# TCP 通道的双向通信
是否有一种本地方法来实现正版频道提供的功能(http://www.genuinechannels.com ) 成分? 本质上,它提供了与 .net 远程处理组件相同的功能,唯一的区别是 .net 远程处理是单向的。 我正在寻找一些东西,作为客户端,我可以连接到服务器,然后将消息传递到服务器,然后让服务器能够将消息传递到客户端(只要服务器需要,客户端无需调用功能)。
谢谢您的帮助!
Is there a native way to implement the features provided by the Genuine Channels (http://www.genuinechannels.com) component? Essentially, it provides the same features as the .net remoting component, with the only difference being .net remoting is unidirectional. I am looking for something where, as a client, I could connect to a server, and then pass messages to the server, and then have the server be able to pass messages to the client (whenever the server wanted, without the client calling a function).
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WCF 标准支持 TCP 的双向支持。
(当 WCF 通过 TCP 进行双向通道时,来自一端的消息可能会阻塞来自另一端的消息。这是因为 WCF 双向通道只允许两端发送消息,它不会在同一网络上创建两个独立的通道。单个 TCP 套接字。)
但是,WCF 不支持单个 HTTP 连接的双向支持,并且 WCF 双向 HTTP 支持无法应对防火墙。
WCF has bydirectional surport over TCP as standard.
(When WCF does bydirectional channels over TCP, a message from one end can block a message from the other end. This is due to the fact that WCF bydirectional channels just allows both ends to send messages, it does not create two independent channels over a single TCP socket.)
However WCF does not have bydirectional surport over a single HTTP connection, and the WCF bydirectional HTTP surport does not cope with firewalls.
您要么必须切换客户端和服务器的角色(即谁在监听,谁在写入),要么您可以在同一端口上打开第二个套接字来提供客户端的服务器。 您的客户端服务器将侦听来自您称为服务器的消息,然后[引发事件|队列|处理]它收到的消息。
You'll either have to switch roles of the client and server (i.e. who is listening and who writes) or you can open a second socket on the same port to provide your client's server. Your client's server is the thing that would listen for messages from what you call the server, and then [raise events|queue|process] the messages it receives.