I am currently doing the client-server (socket) connection in MFC and faced the problem in data exchanging. When client sends a message, a server receives only one time. How to loop it? Please help. Should server wait coming message at all time?
Algorithm:
Server is waiting (listen) always clients request.
When client connects, server creates a thread.
Then data exchanging.
int bytesRecv = SOCKET_ERROR;
char recvbuf[400] = "";
while(bytesRecv == SOCKET_ERROR)
{
int len = 1024;
bytesRecv = recv(recvSocket, recvbuf, len, 0);
if (bytesRecv == 0 || bytesRecv == WSAECONNRESET)
break;
if (bytesRecv < 0)
break;
}