do you query non blocking socket like while (recv(sd..)? just use blocking socket
u_long iMode = 1; // its mean socket set to none blocking!
ioctlsocket(sock, FIONBIO, &iMode);//set client socket to none blocking
int ReceiveTimeout = 10000;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&ReceiveTimeout, sizeof(ReceiveTimeout));
do
{
printf("Repeat socket recv \n");
socket_res = recv(sock, &buffer[0], buffer.size(), 0);
if (socket_res == SOCKET_ERROR)
{
int _iERR = WSAGetLastError();
if (_iERR == WSAEWOULDBLOCK) {
// currently no data available
std::cout << "ERR: its not data currently " << std::endl; // wait and try again
//Sleep(5000);// wait and repeat
continue;
}
//client CLOSE
is_active = false;
continue;
}
else
{
//std::cout << "its data babe: " << _data << std::endl;
_data.append(buffer.cbegin(), buffer.cend());
this->findItemInData();
}
continue;
} while (is_active);