Is there any reason for a blocking call to winsock send() function on Vista to return immediately?

怎甘沉沦 提交于 2019-12-23 02:03:53

问题


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


回答1:


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.




回答2:


probably the out going buffer is full. check the return code from send()



来源:https://stackoverflow.com/questions/2515153/is-there-any-reason-for-a-blocking-call-to-winsock-send-function-on-vista-to-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!