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
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().