CSecureSocket->RecvOneOrMore

Login to reply to this topic.
Fri, 2008-05-09 10:30
Joined: 2007-10-09
Forum posts: 2

Hi,
I’m using the RecvOneOrMore method on CSecureSocket, but I always get just 1 byte back despite the input stream being of several K bytes.

The buffer I’m passing to the method is always cleaned before calling the method, using FillZ() (and Zero()).

If I’m using the Recv method instead, every thing works fine but if the input stream is not a multiple of the buffer I’m using for reading (512) the RunL method of my active object is never called since the buffer cannot be filled on the last read. I cannot use the Recv() method with 1 byte buffer because the scenario I'm facing force me to read more than 1 byte at a time (a timer is running).

Does anyone have any tip on this?

Cheers

Francesco


Fri, 2008-05-09 15:56
Joined: 2006-05-08
Forum posts: 150
Re: CSecureSocket->RecvOneOrMore

Is this on emulator or on a phone?

That's strange. It would be interesting to see what's actually in the underlying TCP socket buffer. Just before you call RecvOneOrMore, you can check how much data is in the socket's q by using the KSoTcpReadBytesPending socket option. Inlcude and link against insock.lib.

// Assuming iSocket is an RSocket instance that you used to create the CSecureSocket instance
TInt bytesYetToBeRead = 0;
User::LeaveIfError(iSocket.GetOpt(KSoTcpReadBytesPending, KSolInetTcp, bytesYetToBeRead));

See what the value of bytesYetToBeRead is.

Can you please post the code you are using too?

Mon, 2008-05-12 10:08
Joined: 2007-10-09
Forum posts: 2
Re: CSecureSocket->RecvOneOrMore

Hi,
thanks for your reply!
I'm currently working on an emulator. Everything seems to work fine on the server side. I already tried to use what you suggested to see if there is more than one byte buffered and the answer is positive

// Assuming iSocket is an RSocket instance that you used to create the CSecureSocket instance TInt bytesYetToBeRead = 0; User::LeaveIfError(iSocket.GetOpt(KSoTcpReadBytesPending, KSolInetTcp, bytesYetToBeRead));

I tried to use the Recv method instead and it is working, I even used the RecvOneOrMore on the RSocket that is passed as a parameter to initialize the CsecureSocket and that is working too.

iSecureSocket = CSecureSocket::NewL( *iStreamConnection->Socket(), KMIDSecureSocketProtocol() )
User::LeaveIfError(iSecureSocket->SetOpt(KSoSSLDomainName, KSolInetSSL, hostname));

Could it be something related to some option I'm not setting?

Hope someone can help me with this.

Thanks a lot

Francesco

  • Login to reply to this topic.