vijayyande / spserver

Automatically exported from code.google.com/p/spserver
Other
0 stars 0 forks source link

数据发送的疑问 #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
数据的发送最终是通过
int spwin32_writev(SOCKET sock, const struct iovec *vector, DWORD count)

{
  DWORD sent = -1;
  WSASend(sock, (LPWSABUF)vector, count, &sent, 0, NULL, NULL);
    return sent;

}
来完成的,WSASend的后面两个参数为NULL,所以发送投递是不会
被GQCS出列的.不被
GQCS出列那么怎么知道实际完成的字节数呢?
那么是不是存在这样一种情况:WSASend产生的发送投递本来是�
��发送100个字节,但是
实际却只发送了80字节?
据我个人的理解,sent中只是返回WSASend往内核的完成队列中投
递的字节数,并不表示
真正发送完成的字节数。
这样不是存在完成字节数与实际投递数不符的情况吗

Original issue reported on code.google.com by FengZhi...@gmail.com on 16 Sep 2009 at 1:23

GoogleCodeExporter commented 9 years ago
忘记说程序版本了,是spserver在svn上的最新代码

Original comment by FengZhi...@gmail.com on 16 Sep 2009 at 1:25

GoogleCodeExporter commented 9 years ago
搞清楚了:此时WSASend实际是阻塞的。
对于非重叠的sockets来说, 最后两个参数(lpOverlapped, 
lpCompletionRoutine) 被忽略,WSASend 
和 
send具有同样的语意。数据从用户缓冲区拷贝到发送缓冲区中�
��应该是指系统的socket堆栈)。如果
socket是非阻塞的又是同时是面向流的(简单地理解为tcp), 
同时发送缓冲区没有足够的大小, WSASend将只
发送用户缓冲区中的部分数据。 
如果同样缓存大小,而socke是阻塞的socket, 
WSASend将阻塞直到用户所
有的数据被发送成功。

Original comment by FengZhi...@gmail.com on 18 Sep 2009 at 4:05

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 19 Mar 2011 at 4:03