是否可以编写像服务器一样执行的程序以及客户端? [英] Is it possible to write program which performs like server as well as client?

查看:87
本文介绍了是否可以编写像服务器一样执行的程序以及客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以创建一个充当多个客户端的服务器的应用程序以及充当主机服务器的客户端?



In我的方案我希望收到来自多个客户端的请求并将此请求发送到另一台具有数据库访问权限的主机服务器,并且该机器将respose发送到我的服务器机器,该服务器最终向客户端发送响应。



请给我任何建议吗?



谢谢。

解决方案

1.是可能的,我在.NET中看到的最佳解决方案是使用WCF。

因此,您的服务器将实现WCF服务,并将提供此接口以与其客户端进行通信。通过与暴露其WCF服务的其他服务器/服务器进行通信,可以成为客户端。



2.我建议您也托管主服务器(也就是客户端) )进入类型窗口的应用程序服务。



3.如果您对速度优化感兴趣,并且您的主服务器和与之通信的其他主机服务器安装在同一服务器/ LAN上他们应该使用 NetPipe 进行通信,否则 NetTcp 绑定是最快的。



4.欲了解更多细节,网上有很多关于WCF主题的文章,包括下一篇:

使用窗口服务在WCF中进行NetPipe绑定 [ ^ ]

使用窗口服务在WCF中进行NetTcp绑定 [ ^ ]

I want to know Is it possible to create a application which acts as a server for multiple clients as well as acts as a client for host server?

In my scenario I want to receive request from multiple clients and send this request to another host server machine which has database access and this machine sends respose to my server machine and this server finally send response to client.

Please give me any suggesstions for this?

thanks.

解决方案

1.Yes it is possible, and the best solution that I see in .NET is by using WCF.
So your server will implement a WCF service and will provide this interface for communication with its clients and also will could be client by communicating with other server/ servers that are exposing their WCF services.

2.I suggest you also to host your main server (that is also client) into an application of type windows services.

3.If you are interesting in speed optimisation, and if your main server and the other host servers that communicates with it are installed on the same server/LAN they should communicate by using NetPipe binding otherwise NetTcp binding is the fastest.

4.For more details there are a lot of article on the net about WCF subject, including the next ones:
NetPipe Binding in WCF using window service[^]
NetTcp Binding in WCF using window service[^]


这篇关于是否可以编写像服务器一样执行的程序以及客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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