本文介绍了加速执行socket.Beginsend的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。



我有多线程TCP IP服务器,必须每秒向其客户发送100条消息。

我正在测试它在500个客户端上,每条消息的大小约为2kb。



我使用SMART Thread Pool将我的服务器开发为多线程应用程序。



多线程工作正常。我正在使用socket .beginsend方法向客户发送消息。



测试时遇到延迟问题:

如果我们说100条消息每秒500个客户端这意味着每秒50000个消息,这需要18秒发送给客户端。



我测试问题是否与我的线程应用程序执行有关线程,但我发现,当我评论beginsend行时,我发现执行不需要超过2秒到达发送方法。



有没有办法加快beginsend的执行速度?

这个行为是否正确?

Hello There .

I have multithreaded TCP IP server which must send 100 messages per second to its clients.
I am testing it on 500 clients and the size of each message around 2kb.

I developed my server to be a multithreaded application using SMART Thread Pool.

The multithreading is working fine. I am using socket .beginsend method to send messages to clients.

While testing I face a delay problem:
If we said 100 message per second to 500 clients this means 50000 message per second this takes 18 seconds to be sent to clients.

I test to see if the problem is with my threading application execution of threads but I found that when I comment the beginsend line I find that the execution does not need more than 2 seconds reaching the sending method.

Is there is a way to speed up the execution of beginsend?
Is this behavior correct ?

推荐答案




这篇关于加速执行socket.Beginsend的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:05