Hello all,
I am writing a function to download a HTML page from another server.
I am wiring this code using MFC's Casyncsocket
Basically, this class runs the callback function (onReceive) whenever it detected some new that can be received.
Originally, I had something like this:
void CLASSNAME::OnReceive(int nErrorCode)
{
char buf[1024];
CString received = "";
while((size = this->Receive(buf, 1023)) > 0)
{
buf[1023] = '\0';
received += buf;
}
}
However, since the Casyncsocket calls this function every time there is something new, these procedures will be called more than once.
So I came up with this:
private CString received = ""; /* Global private variable */
void CLASSNAME::OnReceive(int nErrorCode)
{
char buf[1024];
if((size = this->Receive(buf, 1023)) > 0)
{
buf[1023] = '\0';
received += buf;
}
}
However, with this code, I cannot tell when the HTML is fully downloaded.
Can anyone help me on this?
Thanks.