
July 18th, 2006, 03:30 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Location: The Netherlands
Posts: 5
Time spent in forums: 1 h 3 m
Reputation Power: 0
|
|
|
[C++][Win32] Winsock trouble
Hi,
I'm new to the forum... my name is Peter and i'm dutch.
I'm programming a tool that will get some information out of a website. The problem is that i'll receive a FD_CLOSE message when the socket is closed. But the FD_CLOSE in my program is posted before the FD_READ messages are handled. So i'll receive the rest of the data in FD_CLOSE:
Code:
while((ret != 0) && ret != SOCKET_ERROR) {
ret = recv(hSocket, szData, sizeof(szData), 0);
szData[ret] = 0;
SetFilePointer(receivedData, 0, NULL, FILE_END);
WriteFile(receivedData, szData, strlen(szData), &dwBytesWritten, NULL);
}
But is that a right way to create synchroon socket? Because If I got a page that is huge, and the socket is closed en there is still 100kb of data to read... a slow connection would block the program. Is it possible to receive some kind of message that ALL the data is readed, and the connection has closed gracefully?
Peter.
|