Hi,
I have written a client-server application using Windows sockets
(SOCK_STREAM, TCP), on Windows NT.
Client application needs to send a lot of data to server.
When client sends data slowly, server receives all the data. But when
client sends data very fast, data is lost, and server cannot receive it.
The send() call at client returns success, so client sends next data.
Is there any way by which client can find what happened to previous send(),
before sending next data.
Assuming that Server is too busy doing other computing and has no time to
receive data from Client, at the client side the send() function does not
return any kind of error. So Client keeps on sending data without knowing
that it is being lost.
IMPORTANT : Due to application architectural issues, I cannot send data and
wait for acknowledgment from server before sending next data.
I have already tried following.
1. At the Client end, before calling send() I call select() to check
whether socket is ready to send.
But FD_ISSET macro always returns true.
Documentation for select() says that "writability (FD_ISSET returned
TRUE) means that a send or sendto will complete without blocking"
There is no guarantee that send() will actually send the data.
This did not solve the problem.
2. After send() I save the timestamp. When next send() is called, if time
difference is less than 10 miliseconds, I call Sleep(10);
This gives TCPIP at least 10 miliseconds time in between two send()
calls.
THIS WORKS!
I don't lose data, because at client end socket gets enough time to send
data.
But I really don't want to implement this Sleep(10) logic because when I
keep the Server very very busy doing computing before calling receive(),
again I start loosing data!
Sleep() is just a workaround, not a genuine fix.
In simplest form, to simulate the problem, at client end have a loop to
send data
for(i = 0; i < 1000; i++)
{
if((send((SOCKET) MySocket, (const char FAR *) buffer,(int) LenthOfBuffer,
0)) == SOCKET_ERROR)
break;
printf("count = %d", i)Quote:}
Since send() always return success, I should somehow check whether earlier
send() was done or is TCPIP ready to accept next send()
I do not know at client side whether Server is receiveing the data or not!
PLEASE LET ME KNOW WHERE CAN I FIND INFORMATION SPECIFIC TO SOCKET
PROGRAMMING PROBLEMS/ISSUES/BUGS...
Thanks,
Manoj