C#中的多客户端到服务器 [英] multi client to server in C#
问题描述
嗨大家好:
这个话题听起来对你们有些人来说很熟悉,有些人可以说明一些问题,或者指点一些网站链接获取一些示例代码或好的指南吗?
我能够编写一个简单的客户端到服务器(一对一)而不是这个多客户端场景。
我想要的应用程序建立很简单:
clientx.1 -------------->向服务器发送工作请求
clientx.2 -------------->向服务器发送请求以获得另一份工作
..
....
所有这些活动都必须并发。 ..
如何做到这一点?
谢谢
Hi guys:
This topic might sound very familiar to some of you, can some one shed some light or point me to some web link for some sample code or good guide?
I''m able to code for a simple client to server ( one to one) but not this multi client scenario.
The application that i want to establish is simple:
clientx.1--------------> send a request to server for a job
clientx.2--------------> send a request to server for another job
..
....
all this activities have to be concurrent...
how to do this?
Thanks
推荐答案
@Jetean
使用ThreadPool,您可以在线程上单独运行客户端。
即clientx .1->将在Thread1上运行
clientx.2->将在Thread2上运行...
@Jetean
Use ThreadPool wherein you can run your client(s) separately on thread(s).
ie clientx.1-> will run on Thread1
clientx.2-> will run on Thread2...
您好:
您是否建议在多个线程上运行多个服务器?
这可行吗?
谢谢
Hi:
Are you suggesting to have multiple server running on multiple thread?
Is this viable?
Thanks
@Jetean
不,不是......关于客户。您可以将客户端放在与服务器通信的单独线程上。如果您在客户端拥有共同资源,则可能需要选择客户之间的同步。
@Jetean
No no... Its about client. You can have your client on a separate thread which communicates to the server. If you have common resources across the clients, you may have to opt synchronization between your clients.
这篇关于C#中的多客户端到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!