简体   繁体   English

WCF与WCF双工与套接字

[英]WCF vs. WCF Duplex vs. Sockets

I posted about this before to a degree, but after a few days of reading I have a better understanding of WCF and would like to get a bit of feedback before I start working on it. 我曾经在某种程度上发布过有关此内容的文章,但是经过几天的阅读,我对WCF有了更好的了解,并希望在我开始研究它之前获得一些反馈。

I basically need to develop a server/client system. 我基本上需要开发服务器/客户端系统。 The "server" application (c# net console app) will be ran on a machine with a MySQL database, all software installation packages, and whatever else we need local to it. “服务器”应用程序(c#net控制台应用程序)将在具有MySQL数据库,所有软件安装包以及我们在本地需要的其他任何计算机上运行。 The "client" application (c# net console app) will be ran on the rest of our machines, and will maintain a direct connection to the server software. “客户端”应用程序(c#网络控制台应用程序)将在我们其余的计算机上运行,​​并保持与服务器软件的直接连接。 Using a web front-end, our administrators will be able to install software packages to the clients, create new services, etc. 使用Web前端,我们的管理员将能够将软件包安装到客户端,创建新服务等。

Since we own all of the machines, and have to configure them anyways, Server Push is not a problem. 由于我们拥有所有计算机,并且无论如何都必须对其进行配置,因此服务器推送不是问题。 We don't have to worry about firewalls or any sort of NAT settings as we can just go in and open the ports required for it to operate. 我们不必担心防火墙或任何类型的NAT设置,因为我们可以进入并打开其运行所需的端口。

What initially confused me about WCF is I assocated a "WCF Service" with a server. 最初使我对WCF感到困惑的是我将“ WCF服务”与服务器相关联。 However, since the majority of operations are actually going to be run on the "WCF Service", this is my logic. 但是,由于大多数操作实际上将在“ WCF服务”上运行,所以这是我的逻辑。

1) Make the "client" application actually a "WCF Service" so that the exposed functions are actually ran on the proper machines. 1)使“客户端”应用程序实际上是“ WCF服务”,以便在适当的计算机上实际运行公开的功能。

2) Have the "server" application actually a "WCF Client", and issue all of the instructions/commands from here, and just use the return value to update the database/etc. 2)让“服务器”应用程序实际上是“ WCF客户端”,并从此处发出所有指令/命令,然后仅使用返回值来更新数据库/等。

Would this be the proper method to go follow or should I look into WCF Duplex (Looked extremely confusing at first glance) or just start with raw sockets? 这是遵循的正确方法,还是我应该研究WCF Duplex(乍一看就非常令人困惑)还是仅从原始套接字开始?

from what I gatther you're trying to do, you're correct. 从我试图做的事情来看,你是对的。 That is the client machines should really have a TCP/IP "server" running on them, and the centeral server machine would have the Tcp/IP "Client". 也就是说,客户端计算机上确实应该有一个运行的TCP / IP“服务器”,而中央服务器计算机上应该有Tcp / IP“客户端”。

That way the TCP/IP client (The app running on your server machine) can initiate calls to each of the client machines. 这样,TCP / IP客户端(在服务器计算机上运行的应用程序)可以启动对每个客户端计算机的调用。

Keep in mind also that a single application can be both a tcp/ip client and server. 还请记住,一个应用程序既可以是tcp / ip客户端又可以是服务器。 So your app that's running on the server machine could in turn also be a tcp/ip server that your admin uses to do stuff using a browser. 因此,在服务器计算机上运行的应用程序也可以是tcp / ip服务器,管理员可以使用它来使用浏览器执行操作。 Which effectively means that service is an HTTP service. 这实际上意味着该服务是HTTP服务。

So, it is not a client/server thing. 因此,这不是客户端/服务器。 It is a hub-and-spoke arrangement of distributed computing. 它是分布式计算的中心辐射型安排。 I think, WCF can very well be used. 我认为,WCF可以很好地使用。 You have multiple servers and a coordinator (the client to all of these servers) that gets the work done from various servers and update the database. 您有多个服务器和一个协调器(所有这些服务器的客户端),这些协调器可以从各种服务器上完成工作并更新数据库。

So WCF is well-suited for you. 因此,WCF非常适合您。 The benefit of WCF is the easy configurability and handling the communication part. WCF的好处是易于配置和处理通信部分。 You don't have to take much pain for the management of sockets. 您不必为套接字的管理而费劲。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM