在达到特定数量的连接客户端后,客户端连接基于TCP / IP的服务器的请求将变为挂起。 [英] Client request to connect with TCP/IP based Server becomes pending after reaching some particular number of connected clients.

查看:87
本文介绍了在达到特定数量的连接客户端后,客户端连接基于TCP / IP的服务器的请求将变为挂起。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好大师!

Hello gurus!


问题描述:

推荐答案

幸运我已经在我的代码中找到了问题,我已将其粘贴在下面

Luckily i have figured it out the problem in my code, which i have pasted below

listenForMessageDelegate = new ListenForMessageDelegate(ListenForMessages);
listenForMessageDelegate.BeginInvoke(acceptClient,new AsyncCallback(ListenForMessagesCallback), listenForMessageDelegate);

 listenForMessageDelegate = new ListenForMessageDelegate(ListenForMessages);
                    listenForMessageDelegate.BeginInvoke(acceptClient, new AsyncCallback(ListenForMessagesCallback), listenForMessageDelegate);

private void ListenForMessages(客户端客户端)
{
while(true)
{
.....
... .........}}

private void ListenForMessages(Client client)
{
while (true)
{
.....
........
}
}

由于BeginInvoke在线程池的不同线程中异步运行方法(作为参数传递)。所以在ListenForMessages()永远的while循环保持线程运行。由于这个threadPool exahaust :)。我这样做是因为我需要继续监听客户端和服务器之间的通信消息。

As BeginInvoke runs the method(which passed as its parameter) asychronously in differnt thread from the thread Pool.
So in ListenForMessages() the forever while loop keep the thread running.Due to this threadPool exahaust :). I did that because i need to keep listen for messages for communication among the clients and server.
 


这篇关于在达到特定数量的连接客户端后,客户端连接基于TCP / IP的服务器的请求将变为挂起。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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