且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以编写像服务器一样执行的程序以及客户端?

更新时间:2023-11-28 12:43:10

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[^]