WinhttpReadData 网络慢
我正在使用 Winhttp C++ 从服务器下载 exe。 中提供的示例代码
我使用 MSDN http:/ /msdn.microsoft.com/en-us/library/aa384104%28v=vs.85%29.aspx
它工作正常。我通常用来添加所有读取的数据(从 WinhttpReadData 读取)并记录下来。
预期的结果是,添加的总和应与 exe 大小匹配。它在相当快的网络中运行良好。
如果网络速度很慢。读取的数据比原始大小大太多。但是当我检查下载的exe大小时,它与服务器的大小相同。
日志(将读取的数据相加)显示它读取的数据多于原始大小。
请记住,它仅发生在慢速网络中。有人遇到过这个问题吗?
I am downloading an exe from the server using Winhttp C++. I use the sample code provided in MSDN
http://msdn.microsoft.com/en-us/library/aa384104%28v=vs.85%29.aspx
It works fine.I normally used to add up all the data read (Read from WinhttpReadData) and log it.
The expected result is, the added sum should match the exe size. It works fine in reasonably fast network.
In case of very slow network. The data read is too much larger than the original size. But when i check the downloaded exe size, it is same as that of the server.
The logs (which is adding up the data read) shows it reads more data than the original size.
Remember it only occurs in slow network. Have anyone faced this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尊重通过 lpdwNumberOfBytesRead 参数返回的值?每次调用读取的字节数可能小于您提供的缓冲区大小 - 特别是如果由于网络速度缓慢而导致当时可用的字节数较少。
Are you respecting the value returned via the
lpdwNumberOfBytesRead
parameter? The number of bytes read with each call may be less than the buffer size you provided -- especially if fewer bytes are available at that time due to the slowness of the network.