Hi,
I have a problem related to data transfer between a client and a server, which I don't seem to really understand. The problem is that even though I think I am doing everything as I am supposed to when trying to read data (for a simple class) from client's address space I only get garbage on the server side as a result.
I'll explain my code in more detail in the following. My program is structured in a way that the client and the server run on the same process, but in different threads. The code in the client side handle to the server (derived from RSessionBase) is as follows.
Member variable in the client side handle:
The part of code in the handle which dispatches the request to the server:Code:TParams iParams; // TParams is a simple class with data only members
Member variable in the class derived from CSession and is handling the request from the client:Code:// Put the data descriptor(i.e. source descriptor) into parameters for the server TPtr8 ptr(reinterpret_cast<TUint8*>(&iParams), sizeof(iParams), sizeof(iParams)); TAny* p[4]; p[0] = static_cast<TAny*>(&ptr); p[1] = 0; p[2] = 0; p[3] = 0; // Make asynchronous request to the server SendReceive(EServerRequestId, &p[0], aStatus);
The part of the code on the session class, which tries to read the data to the server side:Code:TParams iParams; // TParams is a simple class with data only members
The client side handle is contained inside an object which has been allocated on the heap, so the data in the source address should remain valid until server tries to read it.Code:// Create the destination descriptor TPtr8 ptr(reinterpret_cast<TUint8*>(&iParams), sizeof(iParams), sizeof(iParams)); // Read data from the source to destination aMessage.ReadL(aMessage.Ptr0(), ptr); // Now the iParams on the server side contains garbage
Am I doing something wrong or have I left out something what is important for the client-server data transfer to work? I really don't know. If you notice something wrong in the code, please give me a hint. I'll appreciate any help you can provide in this problem.
-wilse

Reply With Quote

