双向通信服务器/客户端体系结构? [英] Two way communicating server/client architecture?

查看:76
本文介绍了双向通信服务器/客户端体系结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出用于我们的新应用程序的客户端/服务器技术(即.NET Framework的哪一部分).我们将使用.NET 3.5 SP1以C#编写应用程序.

I'm trying to figure out which client/server technology (i.e. which part of the .NET Framework) to use for our new application. We will be writing the app in C# using .NET 3.5 SP1.

它将由将作为服务器"运行的中央服务以及几个客户端应用程序分布在多台计算机上组成.客户端应用程序是一个trayapp应用程序,它将接收来自服务器的通知,并且还将一些信息发送回服务器.因此,通信将是双向的,并且需要快速.服务器将需要知道向哪个客户端发送通知.

It is going to consist of a central Service that will be running as a "server", and several client applications spread out on several machines. The client application is a trayapp application that is going to receive notifications from the server, and will also send some information back to the server. The communication will therefore be two-way, and it needs to be fast. The server will need to know which client to send the notifications to.

我一直在想可以使用套接字.我也遇到过TcpListener和TcpClient类.另一种选择是使用WCF进行某些操作,但是我不确定如何使用它进行快速的双向通信.

I've been thinking that I could use Sockets. I've also come across the TcpListener and TcpClient classes. Another alternative is to do something with WCF, but I'm not sure how to do fast two-way communication with it.

推荐答案

在不知道您打算交换多少数据的情况下,很难提出准确的建议.我同时使用WCF和TCP套接字在UI和Windows服务之间交换数据.这是我所做的考虑.

Without knowing how much data you're planning to exchange, it's difficult to make a precise recommendation. I use both WCF and TCP sockets to exchange data between my UI and my Windows service. Here are the considerations I made.

我使用WCF进行非定期数据交换.例如,当我的Windows服务中发生事件时,我使用WCF将事件传达给UI.专门针对这种基于事件的机制,我强烈建议Juval Lowy的发布-订阅框架,可免费此处 >.我还使用WCF将配置更改从UI传达到Windows服务. WCF对我来说是用于这种数据交换的完美解决方案.

I use WCF for what I refer to as aperiodic data exchange. For example, when an event occurs in my Windows service, I communicate the event to the UI using WCF. Specifically for this event-based mechanism, I would highly recommend Juval Lowy's Publish-Subscribe Framework, which is available for free here. I also use WCF to communicate configuration changes from the UI to the Windows service. WCF is a perfect solution for this kind of data exchange for me.

当用户告诉我的Windows服务执行某些操作时,许多数据从Windows服务发送到UI.为此,我使用TCP套接字.我知道WCF具有流功能,因此我强烈考虑使用它.在我不得不做出决定之前,我只是没有时间去适应它,所以我顺其自然.

When the user tells my Windows service to perform some action, a lot of data is sent from the Windows service to the UI. For this, I use TCP sockets. I know WCF has a streaming capability, and I strongly considered using it. I just did not have time to get comfortable with it before I had to make a decision, so I went with what I knew.

虽然我希望我在整体上使用WCF来实现对称性,即用于非周期性和流数据,但这种混合方法对我很有帮助.

While I wish I was using WCF across the board for symmetry, i.e., for aperiodic and streaming data, this hybrid approach has served me well.

希望这会有所帮助.

这篇关于双向通信服务器/客户端体系结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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