tags:

views:

59

answers:

1

Hi

I am doing some socket stuff on Symbian, which works fine so far. However, I am facing a weird problem when trying to read out the data that has been sent. Assume the code looks as follows:

TSockXfrLength len;

iSocket.RecvOneOrMore( buff, 0, iStatus, len );  
User::WaitForRequest(iStatus);      
if (iStatus == KErrNone) 
{
   printf(_L("Bytes received 1st try %4d..."), len);
   printf(_L("Bytes Length received 2nd try %4d..."), &len);
}

Output in both cases is something with 7450 although I received exactly 145 bytes. I can check that with a network analyser. Anyone knows what I am doing wrong here that I do not get the proper bytes that have been received?

EDIT:

I am connecting to the socket in the following way: TInetAddr serverAddr;
TUint iPort=445;

 TRequestStatus iStatus;
 TSockXfrLength len;

 TInt res = iSocketSrv.Connect();

 res = iSocket.Open(iSocketSrv,KAfInet,KSockStream, KProtocolInetTcp);

 serverAddr.SetPort(iPort);
 serverAddr.SetAddress(INET_ADDR(192,100,81,54));

 iSocket.Connect(serverAddr,iStatus);

 User::WaitForRequest(iStatus);

Hope that helps ;)

Thanks

+2  A: 

Try

printf(_L("Bytes received 1st try %4d..."), len());

The TSockXfrLength type is actually a typedef of TPckgBuf<TInt>. This is the Symbian Descriptor way of storing arbitrary simple data in a 8-bit descriptor. To retrieve the value from the len object you need to use the () operator.

More information about TPckg* classes are available in the symbian developer library.

Ola
Thanks so much, it works now!