[阅读: 559] 2005-07-28 03:19:25
static WN_INT _dwrite(WN_INT fd, void * buf, WN_INT len)
{
WN_INT wlen = 0;
while (wlen < len)
{
WN_INT ret = send(fd, ((char *)buf)+wlen, len-wlen, 0);
if (ret < 0)
{
TRACE("write to %d error!\n", fd);
return -1;
}
wlen += ret;
}
return wlen;
}
我理解TCP协议是流的概念,如果不设某个socket 属性(记不得是哪个了)的话,即使调用多次send 协议底层可能根据具体的数据长度和时间状况自决定到底发几个数据包出去.