Vista 上对 winsock send() 函数的阻塞调用是否有任何原因立即返回?
Vista 上对 winsock 的 send() 函数的阻塞调用是否有任何原因立即返回?在 XP 及更低版本上,它会出现预期的延迟。我想知道这是否与 Vista 的自动调整功能有关。 代码:
char *pBuffer; // pointer to data
int bytes; // total size
int i = 0, j=0;
while (i < bytes)
{
j = send(m_sock, pBuffer+i, bytes-i, 0);
i+=j;
}
谢谢,
帕万
Is there any reason for a blocking call to winsock's send() function on Vista to return immediately ? It works with expected delay on XP and below. I'm wondering if this has got anything to do with auto-tuning feature of Vista.
Code:
char *pBuffer; // pointer to data
int bytes; // total size
int i = 0, j=0;
while (i < bytes)
{
j = send(m_sock, pBuffer+i, bytes-i, 0);
i+=j;
}
Thanks,
Pavan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一种可能是send()失败并返回SOCKET_ERROR。您的代码无法检测到这一点,您确实应该修复它。
下一个可能性是 send() 只是不阻塞。这是很正常的,只有当传输子系统中没有剩余缓冲区空间时它才会阻塞。在此之前,您必须泵送几兆字节。
The first possibility is that send() failed and returned SOCKET_ERROR. Your code cannot detect this, you really ought to fix that.
The next possibility is that send() just doesn't block. Which is pretty normal, it will only block when there's no buffer space left in the transport sub-system. You'll have to pump several megabytes before that happens.
可能输出缓冲区已满。检查 send() 的返回码
probably the out going buffer is full. check the return code from send()