有关发送的问题 [英] question regarding send

查看:67
本文介绍了有关发送的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在调用send函数以阻塞模式发送1GB数据时函数会立即返回?套接字发送缓冲区不能为1GB。

解决方案

您好,


您能否请出示代码或代码示例?你有没有检查send方法的返回值?

无论如何,只有当套接字在阻塞模式下运行并且套接字的出站缓冲区填满了排队数据时,send()才会阻塞。从发送时的MSDN文档:

https ://docs.microsoft.com/zh-cn/windows/desktop/api/winsock2/nf-winsock2-send

"成功完成发送功能并不表示数据已成功传递并接收给收件人。此功能仅表示数据已成功发送。" 



不仅如此,它实际上并不表示数据已成功发送到接收方,而是它已在套接字的出站缓冲区中成功排队,以便以后传输到接收方。如果send()阻塞,则意味着套接字以
阻塞模式运行并且队列已满,等待接收器读取并确认某些数据,以便在队列中打开空闲空间。





最好的问候,

Drake


hi, Why the function immediately returns when calling the send function to send data of 1GB in a blocking mode? The Socket send buffer cannot be 1GB.

解决方案

Hi,

Could you please show your code or a code sample? Have you check the return value of the send method?
Anyway, send() blocks only if the socket is running in blocking mode and the socket's outbound buffer fills up with queued data. From the MSDN documentation on send:
https://docs.microsoft.com/zh-cn/windows/desktop/api/winsock2/nf-winsock2-send
"The successful completion of a send function does not indicate that the data was successfully delivered and received to the recipient. This function only indicates the data was successfully sent." 

More than that, it actually does not indicate that the data was successfully sent to the receiver, but that it was successfully queued in the socket's outbound buffer for later transmission to the receiver. If send() blocks, it means the socket is running in blocking mode and the queue is full, waiting for the receiver to read and ack some data so free space opens up in the queue.

Best Regards,
Drake


这篇关于有关发送的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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