PDA

View Full Version : ISOURCE_Read - Unpredictable results


cpiazza
06-04-2002, 12:47 PM
i'm using ISOURCE_Read to collect binary data being sent as the reasponse to an HTTP Post request.

what i first noticed that that the _Read would return without actually getting all the data being sent back. so i decided to enter a loop, after the initial read, as such:

iBytesRead = ISOURCE_Read(pwri->pisMessage, cb, BUFFER_SIZE);

while (iBytesRead < pwri->lContentLength)
{
iBytesRead += ISOURCE_Read(pwri->pisMessage, cb+iBytesRead, BUFFER_SIZE-iBytesRead);
}

no, this all works fine when i'm debugging, but when executed from outside the debugger i get the following error:

Memor Corruption
SocketRead

which i first though was some buffer overflow, and usually when things work in the debugger and don't when executed normally it's been some sort of data initialization problem, but here it's not the case.

Any ideas?

Kevin
06-06-2002, 11:11 AM
You should register for a callback via ISOCKET_Readable. You can refer to the Socket example included in the SDK.

cpiazza
06-06-2002, 12:58 PM
I've already got the callback registered -

CALLBACK_Init(&me->cb, WebAction_GotRestoreResp, me);
ISOURCE_Readable(pwri->pisMessage, &me->cb);

The above two lines are getting execute if the first read attempt returns ISOURCE_WAIT.

The problems I'm encountering are happening when the callback function is finally getting called.