本文介绍了多端口,多线程套接字通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拜托,我急需你的帮助。我的电子邮件是[删除] @ [无需知道] .com

我认为我的问题应该是线程的问题。我有大约五个线程同时运行,所有五个线程都在进行类似的处理(i:e在端口上收听,接收数据等)。



但是当1线程接收数据并开始处理它,其中一个线程停止运行,其余线程仍在激活并运行。





代码很多,这就是为什么我没有发布它。实际上我在不同的线程中有5个不同的模块。每个模块正在侦听端口以获取即将到来的连接请求,并检查数据到达这些端口。 1个线程处理TEXT消息,处理并将其分发给客户端。然后另一个线程处理即将到来的文档,然后将其传递给子程序,该子程序将文件写入服务器,等待客户端对doc的请求。但是一旦调用该例程(文档例程),文本消息的线程就会停止运行或处理。这意味着,没有客户可以再进行通信。



代码有点笨重,这就是我删除它的原因。

Please, I need your help urgently. my email is [deleted]@[no need to know].com
I think my problem should be an issue with thread. I have about five threads running at the same time and all five doing similar processing (i:e Listening on a port, receiving data etc.).

but when 1 of the thread receives data and start processing it, 1 of the thread stops running while the rest are still active and running.


The codes are much that''s why I didnt post it. Actually I have 5 different modules in different threads. each of the module is listening on a port for in coming connection request and also checking the arrival of data on those ports. 1 thread handles TEXT messages, process and distributes it to clients. Then another thread handles in coming documents, then pass it to a subroutine that writes the file on the server pending a clients request for the doc. but as soon as that routine (document routine) is called, the thread for text messages stops running or processing. that means, that no client can communicate any more.

the code is a little bulky, that was why i removed it.

推荐答案

Quote:

这些代码就是我没有发布的原因。

The codes are much that''s why I didnt post it.




引用:

代码有点笨重,这就是我删除它的原因。

the code is a little bulky, that was why i removed it.



看起来自己在代码中迷失了。我会(如果可能的话)关闭所有可能的噪音(例如,您可能会使用条件编译并在时间n)检查一个元素(即一个线程)。这样你就可能找到问题。


It looks yourself are lost in your code. I would (if possible) switch off all the possible noise (for instance you might use conditional compilatio and inspect one element (that is one thread) at time n). This way you may possibly locate the problem.



这篇关于多端口,多线程套接字通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:37