×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Aug 2004
    Posts
    94

    why get zero length recvbuffer when socket recv() return?

    HBufC8* pkgBuffer = HBufC8::NewL(readLen +1);
    TPtr8 auxPtr(( TUint8* )pkgBuffer->Des().Ptr(), readLen);

    iRecData.Set(auxPtr);
    iSocket.Recv(iRecData, 0, iStatus, iDummyLength);

    if (iRecData.Length() != 0)
    {
    iBuffer.Append(iRecData);

    }

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    did you check that there were no error's when the RunL was called ?

    yucca

  3. #3
    Regular Contributor
    Join Date
    Aug 2004
    Posts
    94
    I recv the packages size like 34,43,53.
    the first 4bytes in every package to get the next package size(the head and the body).

    I want to read message size ordered like 4,30, 4,39 ,4,49

    But I recv more then 34 bytes after the server send the first 34 bytes package.
    I debug program like this:
    RecvOneOrMore(headBuffer);//get nothing
    RecvOneOrMore(headBuffer);//get 4 bytes and the value is right
    RecvOneOrMore(bodyBuffer);//get 30 bytes and the value is right
    RecvOneOrMore(headBuffer);//get 4 bytes and the value is wrong.the value is the first 4bytes of the bodyBuffer.



    why????


    RunL()
    {
    IssueRead() ;
    }
    void CSocketsReader::IssueRead()
    {
    // Initiate a new read from socket into iBuffer
    __ASSERT_ALWAYS(!IsActive(), User::Panic(KPanicSocketsEngineRead, ESocketsBadState));

    if (!bRecvNext)//read 4 size ,the head
    {
    iSocket.RecvOneOrMore(headBuffer, 0, iStatus, iDummyLength);
    //User::WaitForRequest(iStatus);
    if (headBuffer.Length() != 0)
    {
    iBuffer.Append(headBuffer);
    headBuffer.FillZ();
    headBuffer.Zero();
    if (iBuffer.Length() >= 4)
    {
    TInt16 aLen;
    Mem::Copy((void *)&aLen,(const unsigned short *)(iBuffer.Ptr()+2),2);
    if (aLen != 0)
    {
    readLen = aLen ;
    bRecvNext = TRUE;
    }
    }
    }
    }
    else//recv the body
    {
    HBufC8* pkgBuffer = HBufC8::NewL(readLen +1);
    TPtr8 auxPtr(( TUint8* )pkgBuffer->Des().Ptr(), readLen);

    iRecData.Set(auxPtr);
    iSocket.RecvOneOrMore(iRecData, 0, iStatus, iDummyLength);

    if (iRecData.Length() != 0)
    {
    iBuffer.Append(iRecData);

    iBuffer.FillZ();
    iBuffer.Zero();
    bRecvNext = FALSE;
    }
    }
    SetActive();
    }
    Last edited by agirllikeyou; 2004-10-12 at 12:08.

  4. #4
    Regular Contributor
    Join Date
    Aug 2004
    Posts
    94
    i changed the steps orders and it works now.
    the steps is :
    1.recvheadBuffer() and setactive().
    2.RunL()
    {
    check if get headBuffer()
    {
    recvbodyBuffer()
    }
    else
    {
    recvheadBuffer()
    }
    check if get bodyBuffer()
    {
    recvheadBuffer()
    }
    else
    {
    recvBodyBuffer()
    }

    setactive
    }

Posting Permissions

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