bool Socket::sendAll(void *buffer, int size) {
if (!isValid()) return 0;
char *ptr = (char*) buffer;
int counter = 0;
while (size > 0)
{
int sz = ::send(m_sock, ptr, size, 0);
usleep(1000);
if (sz < 1) {
counter++;
if (counter > 10000) return false;
continue;
}
ptr += sz;
size -= sz;
}
return true;
}