×

Discussion Board

Results 1 to 2 of 2

Thread: Sockets example

  1. #1
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Tampere, Finland
    Posts
    58

    Sockets example

    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.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167
    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.

    yucca

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×