Send 和 WSASend
来源:互联网 发布:sqlplus执行sql文件 -c 编辑:程序博客网 时间:2024/05/22 09:47
socket本身有一个send函数,这个函数的只能一次发送一个缓冲区,这对于在发送大量数据的时候或者数据包很多的时候就可能导致系统的低性能,主要原因在于调用太多次的send函数,导致从用户态到核心态的不断切换,而耗费了当前的CPU时钟周期。
那么解决办法就是减少调用send的次数,一种办法就是使用一个大一点的BUFFER,在发送数据的时候将多个数据包的内容COPY到这个BUFFER中,然后一次发送,这样在一定程度上减少了send的调用次数,但需要一定的编码工作。
Windows平台上有一个WSASend函数,可以支持一次发送多个BUFFER的请求,每个被发送的数据被填充到WSABUF结构中,然后传递给WSASend函数同时提供BUF的数量,这样WSASend就能上面的工作而减少send的调用次数,来提高了性能。
实际检验证明,使用WSASend可以提高50%的性能甚至更多。
PS:禁用Nagle算法的时机:
"Aside from these problems, disabling the Nagle algorithm almost always causes a program's throughput to degrade. The only time you should disable the algorithm is when some other consideration, such as packet timing, is more important than throughput.
Often, programs that deal with real-time user input will disable the Nagle algorithm to achieve the snappiest possible response, at the expense of network bandwidth. Two examples are X Window servers and multiplayer network games. In these cases, it is more important that there be as little delay between packets as possible than it is to conserve network bandwidth."
原文:http://blog.csdn.net/pud_zha/article/details/8033595
- Send 和 WSASend
- send和WSASend区别
- Send 和 WSASend
- send 和 WSASend性能比较
- send 和 WSASend性能比较
- 9.什么是send或者WSASend?
- WSASend()
- WSASend
- WSASend
- WSASend
- IOCP WSASend()
- send和recv函数
- Send和Recv函数
- send和recv函数
- send和recv函数
- send和recv
- send() 和recv()
- python yield和send
- 调试没有符号的驱动时如何断在入口点处
- GoAgent原理与实现(二):本地代理的C#试验
- HDU 4418 Time travel (概率,高斯消元)
- Word 2010如何从正文开始设置页码
- 【Android开发那点破事】打开APP加载页面实现
- Send 和 WSASend
- 键盘管理
- 给单选框赋值
- 设计模式:抽象工厂模式(4.2)C++版
- 获取网络数据中的数组显示成ListView的简单流程
- strtok
- 标准模板库(STL)学习探究之Multimap容器
- FTP文件上传下载删除_解决乱码.doc
- Java中的String思考。