views:

132

answers:

2

Hi All,
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  A: 

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

steelbytes
+2  A: 

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.

Hans Passant
nobugz, In the case of second possibility (of buffer being too big), do you think setting the buffer size on the socket will help ? I will try it anyway :)
ivymike
@ivymike: How does it HELP to make send() block? Help for what? Everyone else would be happy seeing it's send() calls not to block!
rstevens
Agreed, that doesn't need fixing.
Hans Passant