// JP opened flex table

Click to See Complete Forum and Search --> : recv error and synchronization problems


Harko
February 15th, 2007, 07:42 AM
hello,
we use an async. socket for message handling:


WSAAsyncSelect(s, g_iohwnd, SOCKET_IO_MESSAGE, (FD_ACCEPT | FD_CONNECT | FD_READ | FD_CLOSE | FD_WRITE));




socket messages are directly handled in the g_iohwnd window message loop. Everything works fine beside:


status = recv(
m_clsocket,
(char *)(InputData.m_buffer + InputData.m_buffer_size),
RECV_SIZE,
0);

if(status == 0)
{
Console.ErrorMsg("recv: status = 0, socket closed", status);
CloseClient();
return;
}
else if(status == SOCKET_ERROR)
{
status = WSAGetLastError();
if(status != WSAEWOULDBLOCK)
{
Console.ErrorMsg("recv failed: reason %d", status);
CloseClient();
return;
}
else
{
break;
}
}


-> server sends data
-> server close the connection
-> message loop receive FD_READ but recv returns 0 (gracefully closed socket)

this happens mainly with slow connections. The data send directly before closing the socket is lost ... what can I do?

wildfrog
February 15th, 2007, 02:15 PM
The data send directly before closing the socket is lost ... what can I do?Use a network packet sniffer to determine if the 'lost' packet is sent from the client and if it ever reaches the target host. That way you'll know what side (if any) that's failing.

- petter

//JP added flex table