Winsock 2.2 problem on recv(), help please!!

23/02/2004 - 12:56 por Iker Landajuela | Informe spam
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);
}
}

Preguntas similare

Leer las respuestas

#1 Phil Frisbie, Jr.
23/02/2004 - 17:31 | Informe spam
Iker Landajuela wrote:

Hi,
IŽm programming a client socket application, my application hangs when
calling to recv the second time inside the for, why?????



recv() by default is a blocking call, so it means it is waiting for something to
read and no more was sent. If this is a TCP socket, and you think the other end
is sending two or more messages, then you need to first understand that TCP is a
stream, and NOT packets.

Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida