本文介绍了有没有任何理由阻止调用winsock send()函数在Vista上立即返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有理由阻止调用Winsock的send()函数在Vista上立即返回?它在XP及以下的预期延迟工作。我想知道这是否与Vista的自动调整功能有关。
代码:


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;
   }

感谢,

Pavan

Thanks,
Pavan

推荐答案

第一种可能是send()失败并返回SOCKET_ERROR。您的代码无法检测到这一点,您真的应该解决这个问题。

The first possibility is that send() failed and returned SOCKET_ERROR. Your code cannot detect this, you really ought to fix that.

下一个可能性是send()不会阻塞。这是很正常的,它只会阻塞时,在传输子系统中没有剩余的缓冲区空间。你必须在这之前泵几兆字节。

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.

这篇关于有没有任何理由阻止调用winsock send()函数在Vista上立即返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 22:12