Why doesn\'t send() in winsock guarantee delivery of the all bytes you request?
This is TCP and it\'s blocking sockets.
Similarly,
This behaviour is "by design".
You can use an outer loop as shown in this example:
int sendBuffer (SOCKET ClientSocket, const char *buf, int len, int flags)
{
int num_left = len;
int num_sent;
int err = 0;
const char *cp = buf;
while (num_left > 0)
{
num_sent = send(ClientSocket, cp, num_left, flags);
if (num_sent < 0)
{
err = SOCKET_ERROR;
break;
}
assert(num_sent <= num_left);
num_left -= num_sent;
cp += num_sent;
}
return (err == SOCKET_ERROR ? SOCKET_ERROR : len);
}