×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    4

    eSock Panic 14 - but code works if using blocking User::WaitForRequest

    Hi everybody,

    I¡¯ve got a very mysterious problem. I¡¯m writing a Bluetooth application for the Nokia 7650 which talks with a C based program running under Linux with the bluez stack.
    The both programs communicate with each other through a TL protocol (type, length). That means that the C program sends in his first write the type ( 4 byte int ) and the length of the payload ( 4 byte int ) und in the second write the payload itself.
    On the other side the symbian application reads the first 8 byte and then creates a buffer of appropriate size to store the payload.

    This reading part is implemented as an Active Object. Now my problem: ( please see attached code-snips).
    When I call the method ¡°IssueReadHeaderL¡± I get a ¡°eSock Panic 14¡±. But when I call the following code

    IssueReadHeaderL()
    User::WaitForRequest( iStatus );
    IssueReadBodyL()

    the application works. But this code blocks which in turn disables an other part of my application so I need to get rid of that.

    Any help is welcome, TIA
    Lukas

    void BTDReader::RunL() {
    switch ( iStatus.Int() ) {
    case KErrNone:
    if ( iBTDReaderStatus == ERecvBody ) {
    // do something with the received Message
    } else {
    IssueReadBodyL();
    }
    break;
    case KErrDisconnected:
    iRn.Disconnect();
    break;
    default:
    break;
    }
    }

    void BTDReader::IssueReadHeaderL() {
    __ASSERT_ALWAYS( !IsActive(), User::Panic( _L("BTDReader: Active"), 1 ) );
    receiveHeaderL( iSocket, iStatus );
    ChangeStatus( ERecvHeader );
    SetActive();
    }

    void BTDReader::IssueReadBodyL() {
    __ASSERT_ALWAYS( !IsActive(), User::Panic( _L("BTDReader: Active"), 1 ) );
    receiveBodyL( iSocket, iStatus );
    ChangeStatus( ERecvBody );
    SetActive();
    }

    void BTDReader::receiveHeaderL( RSocket& _socket, TRequestStatus& status ) {
    delete iHeader; iHeader = NULL;
    iHeader = HBufC8::NewL( 2*sizeof(TInt32) );
    TPtr8 headerPtr( iHeader->Des() );
    _socket.Recv( headerPtr, 2*sizeof(TInt32), status );
    }

    void BTDReader::receiveBodyL( RSocket& _socket, TRequestStatus& status ) {
    TInt32 len;

    TPtr8 headerPtr( iHeader->Des() );
    RDesReadStream reader( headerPtr );
    iType = reader.ReadInt32L();
    len = reader.ReadInt32L();

    delete iBuf; iBuf = NULL;
    iBuf = HBufC8::NewL( len );
    TPtr8 bufPtr( iBuf->Des() );
    _socket.Recv( bufPtr, len, status );
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Kiev, Ukraine
    Posts
    20
    Hi,

    I am facing the same problem. Any solutions found?

    Thank you.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Kiev, Ukraine
    Posts
    20

  4. #4
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    58
    I believe this answer has been found in other posts on this site, but just to be clear. I struggled with the eSock Panic 14 for weeks, running into problems on reads and connects.

    The problem lies with the API for methods such as Recv and Open. Take the following two lines from the above example:

    TPtr8 headerPtr( iHeader->Des() );
    _socket.Recv( headerPtr, 2*sizeof(TInt32), status );


    The Recv() method accepts a TDes8& as the first argument. That reference is being used to populate the results of the receive. You've assumed (as I did) incorrectly that Symbian makes a copy of the reference.

    I really think they should, and if they did the results of the receive would be placed in iHeader->Des(). Instead, the results of the receive are placed in precisely the TDes8& object passed in. Meaning the object on headerPtr on the stack, which dollars to donuts isn't going to be around when the receive comes to pass.

    The solution is to make sure that all objects passed in to these functions remain in scope. Make them attributes of your class, just like iHeader->Des().

    -c

Posting Permissions

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