Windows IOCP-WSASend().有关数据缓冲区的不确定性. [英] Windows IOCP - WSASend(). Unclarity regarding the data buffers.

查看:305
本文介绍了Windows IOCP-WSASend().有关数据缓冲区的不确定性.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

摘录自
http://msdn.microsoft.com/zh-cn/library/ms742203%28VS.85%29.aspx
阅读后以下两行让我有些困惑;

Hi!

Taken from
http://msdn.microsoft.com/en-us/library/ms742203%28VS.85%29.aspx
After reading the following two lines I'm a bit confused;

For a Winsock application, once the WSASend function is called, the system owns these buffers and the application may not access them. This array must remain valid for the duration of the send operation.


Data is copied from the buffer(s) into the transport's buffer.


看到了吗?第二行告诉我,数据正在复制到传输的缓冲区,据我所知,这意味着原始缓冲区可供操作.

另一方面,第一行告诉我对于发送操作的持续时间",我已发送的这些缓冲区必须为有效".和发送操作的持续时间" ????

同样,如果我理解正确的话; -不能在栈上分配缓冲器,否则当函数退出时,该存储器不再有效". (可变范围).

发送操作的持续时间" -真的不清楚.这是否意味着我必须等待写入完成"?完成端口通知?

请告知,非常感谢!


这是我要分享的信息(=


See? The 2nd line tells me that the data is being copied to the transport's buffer, meaning, from what I understand, that the original buffer is free for manipulations.

On the other hand, the 1st line tells me that these buffer(s) that I've sent must be "valid", for the "duration of the send operation".
Define "valid" and "duration of the send operation"???

Again, if I understand right;
"valid" - Buffer cannot be allocated on the stack, otherwise when the function exits, this memory is no longer "valid". (variable scope).

"duration of the send operation" - Really not clear. Does this mean that I have to wait for the "write complete" completion port notification?

Please advise, thank you very much!


This is the information I want to share (=

推荐答案

由于函数是异步的,因此不能保证函数返回后立即将数据复制到传输提供程序,因此必须确保缓冲区与数据一起存在,直到获得完成通知为止.
It's not guaranteed that the data is copied to the transport provider as soon as the function returns since it's asynchronous, so you must guarantee that the buffer exists with the data until you get the completion notification.


这篇关于Windows IOCP-WSASend().有关数据缓冲区的不确定性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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