TCP下socket的send函数发送的字节数可能小于要求发送的字节数,send_n用得太频繁,没办法,自己写了一个。
无甚技术含量,勉强够用^_^
int send_n(SOCKET s, const char *buf, int len, int flags)
{
int result, old_len = len;
do {
result = send(s, buf, len, flags);
if (result == SOCKET_ERROR)
return SOCKET_ERROR;
len -= result;
buf += result;
} while (len);
return old_len;
}
责任编辑:小草