Advertisement
Advertisement

新足迹

 找回密码
 注册
新足迹 › 门户 › AI 相关› 查看内容

谁懂API?

2013-2-21 12:12| 发布者: tennisBoy | 查看: 3946| 原文链接

谁能解释一这下缓冲区的程序?

//缓冲区可写性测试
                                if (FD_ISSET(sockinfo->socket, &fdwrite))
                                {
                                        sockok--;
                                       
                                        //继续发送剩余部分
                                        sockinfo->wsaBuf.buf = sockinfo->buf + sockinfo->bytesend;
                                        sockinfo->wsaBuf.len = sockinfo->bytesrecv - sockinfo->bytesend;
                                        if (WSASend(sockinfo->socket,
                                                &(sockinfo->wsaBuf), 1, &datasend, 0,
                                                NULL, NULL) == SOCKET_ERROR)
                                        {
                                                if (WSAGetLastError() != WSAEWOULDBLOCK)
                                                {
                                                        printf("Send failed with error\n");
                                                        FreeSocketInfo(index);
                                                }
                                               
                                                continue;
                                        }
                                        else
                                        {
                                                //增加已发送数据计数
                                                sockinfo->bytesend += datasend;
                                                //二者相等时说明接收数据已发送完毕
                                                if (sockinfo->bytesend == sockinfo->bytesrecv)
                                                {
                                                        sockinfo->bytesend = 0;
                                                        sockinfo->bytesrecv = 0;
                                                        ZeroMemory(sockinfo->wsaBuf.buf,BUFFERSIZE);
                                                }
Advertisement
Advertisement


Advertisement
Advertisement
返回顶部