Hi,
I´m programming a client socket application, my application hangs when
calling to recv the second time inside the for, why?????
int iReturn; // Return value of recv function
char *szClientA;
TCHAR szClientW[400]; // Unicode string
int index = 0; // Integer index
for (;;)
{
szClientA=(char *)malloc(200);
//here stops the execution!!!!
iReturn = recv ( ServerSock, szClientA, 200, 0 );
if (iReturn == SOCKET_ERROR)
{
Puts(L"SOCKET_ERROR en recv");
GetError(L"recv()",WSAGetLastError());
free(szClientA);
return false;
break;
}
else if (iReturn == 0)
{
free(szClientA);
break;
}
else
{
// Convert the ASCII string to a Unicode string.
for (index = 0; index <= 400/*sizeof (szClientA)*/; index++)
szClientW[index] = szClientA[index];
// Display the string received from the server.
Puts(szClientW);
free(szClientA);
}
}
Leer las respuestas