18,356
社区成员
发帖
与我相关
我的任务
分享
//方法一
char sendbuff[2048];
int nBytes = 2048;
//一些初始化代码
ret = send(s, sendbuff, nBytes, 0);
/***************************************************/
//方法二
char sendbuff[2048];
int nBytes = 2048;
int nLeft = nBytes;
int idx = 0;
//一些初始化代码
while(nLeft > 0) {
ret = send(s, &sendbuff[idx], nLeft, 0);
if (ret == SOCKET_ERROR) {
//错误处理
}
nLeft -= ret;
idx += ret;
}