Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Symbian > Receiving data ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 103 of 155
Post > Topic >>

Receiving data with size not multiple of 8 bytes

by cris_miron@[EMAIL PROTECTED] (Cristian Miron) Oct 26, 2004 at 06:08 AM

Hi, 

I have a problem. Based on the value of some data already read in, I
want to receive some data via bluetooth. I set the amount of data read
dynamically like this:

HBufC8 *iReceiveData = HBufC8::NewL(iRecvSize); 

And then I use RSocket::Recv method to receive data, like this: 

TDes8 *Buf = &m_HBuf_ReceiveAckData->Des(); 
iSocket.Recv(*Buf, 0, iStatus); 
SetActive(); 

If my data size to receive iRecvSize is not a multiple of 8, the
maximum length alocated for HBufC8 is multiple of 8, by design:
"It is important to note that the size of the allocated cell, and,
therefore, the resulting maximum length of the descriptor, may be
larger than requested due to the way memory is allocated in Symbian
OS. The amount by which this may be rounded up depends on the platform
and build type." (Symbian SDK)

But, RSocket::Recv is a little weird: 
"For a stream-interfaced sockets, the function only completes when the
full amount of requested data has been received (or the connection
breaks). This means when the descriptor has been filled to its
__maximum__ length (__not its current length__). " (Symbian SDK)

So, if I send 3 bytes, Recv will expect 4 or 8 bytes.  
I don't want to use RecvOneOrMore. What should I do? 

Thank you. 

Cristian Miron




 2 Posts in Topic:
Receiving data with size not multiple of 8 bytes
cris_miron@[EMAIL PROTECT  2004-10-26 06:08:22 
Re: Receiving data with size not multiple of 8 bytes
"Bo Rydberg" &l  2004-10-26 21:15:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 17:33:18 CDT 2008.