简体   繁体   English

C#NET服务器/客户端应用程序

[英]C# NET Server/Client Application

I am starting on a fairly basic Server/Client application (logic wise), but I am a bit confused as to what I should use for my needs. 我开始使用一个相当基本的服务器/客户端应用程序(逻辑上明智),但我对我应该用于什么需求感到困惑。 It looks like there a few options, but basically I am going to have a Master Server, and X amount of client applications (one per dedicated machine). 看起来有几个选项,但基本上我将拥有一个主服务器和X个客户端应用程序(每个专用机器一个)。 The main purpose of this setup is so that I can basically do the following... 这个设置的主要目的是让我基本上可以做到以下几点......

-Issue command to server (console app) via an ASP front end to install software on one of the remote clients. - 通过ASP前端向服务器(控制台应用程序)发出命令,以在其中一个远程客户端上安装软件。 - Server tells client to download zip package (from a various FTP site) to location and extract it to specific path. - 服务器告诉客户端将zip包(从各种FTP站点)下载到位置并将其提取到特定路径。

I am not positive, but it looks like C# has Sockets and then some sort of WebClient type of deal. 我不是肯定的,但看起来C#有Sockets,然后是某种WebClient类型的交易。 I am assuming Sockets would be the best route to take, and to use asynchronous (each remote client is connected in its own thread, dealing with the server individually of others). 我假设套接字是最好的路由,并使用异步(每个远程客户端连接在自己的线程中,与其他人单独处理服务器)。

Any information on this would be great! 有关这方面的任何信息都会很棒!

Without going into too much detail for your specific requirements, I would definitely look at WCF . 如果没有针对您的具体要求进行过多详细介绍,我肯定会关注WCF

It encompasses a lot of the existing remoting, client / server, web services scenarios in a very complete and secure framework. 它在一个非常完整和安全的框架中包含了许多现有的远程处理,客户端/服务器,Web服务方案。

Client Server Programming with WCF 使用WCF进行客户端服务器编程

WebClient allows you to make HTTP requests, so I don't think it's very relevant here. WebClient允许您发出HTTP请求,因此我认为这与此无关。

There are many approaches you can take for this app. 您可以为此应用程序采取许多方法。

One is of course going with WCF, which provides about a million time more options than you will need. 一个当然是与WCF一起使用,它提供的选项比你需要的时间多出一百万。 However, WCF does have a learning curve and in particular it's hard to understand what exactly is hidden behind all the abstractions without prior experience. 然而,WCF确实有学习曲线,特别是在没有经验的情况下很难理解所有抽象背后究竟隐藏了什么。 Furthermore, this solution is not available if you are targeting .NET 2.0. 此外,如果您的目标是.NET 2.0,则此解决方案不可用。

You can also implement a simple TCP client/server model using sockets. 您还可以使用套接字实现简单的TCP客户端/服务器模型。 While you can program against raw sockets, .NET also offers the convenience classes System.Net.Sockets.TcpListener for the server and System.Net.Sockets.TcpClient for the clients. 虽然你可以对原始套接字编程,.NET还提供了方便的类System.Net.Sockets.TcpListener服务器和System.Net.Sockets.TcpClient的客户。 This approach is much closer to the metal, but this is a tradeoff: it's much easier to understand what exactly you are doing, but you will have to implement a fair bit of functionality yourself. 这种方法更接近于金属,但这是一个权衡:更容易理解你究竟在做什么,但你必须自己实现一些功能。

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

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