I have modified Nokia Sockets Example (delivered with s60 sdk) and when I try to send binary data from file to socket, the buffer will run out of space.
This is how sending is done...
<mycode>
TBuf8<10> filepart;
while (retval != KErrEof)
{
retval = file.Read(pos, filepart, 10);
if (filepart.Length() < 1) break;
pos = pos + 10;
TRAPD(err, iSocketsEngine->WriteL(filepart)); // engine of socketsex
if (err != KErrNone)
{
RDebug::Print(_L("ERROR: Image write"));
return;
}
filepart.Zero();
}
</mycode>
The sockets example writer only writes about first 100kt of file and then Leaves with error KSocketExampleOverFlow. Looks like CActiveShceduler does not give enough time to CSocketWriter. Should I do anything else in my code to be sure that all packets have been sent? I have tried my code on emulator and on device.
I think that the problem is propably your while() -loop. Basically as soon as you enter the loop, it will run till it exists, so non of the other active objects will be able to do anything while you are in your loop.
So try reading a bit bigger chunk from the file and then write it out with a function that takes iStatus as an argument, then wait it to return and call call your RunL, before proceeding to send the next chunk. Or just read the file completely into a buffer and sent it out. Then remember to give to socket a reference to the buffer that is not going invalid (i.e. not a automatic variable inside function, but a member variable of the CActive defived class), othervise you'll find a new problem in there.