newlc.com
Articles Only
Forum Only
Community
World-Wide Web
Home
News
Tutorials
Reviews
Downloads
Professional Services
Forums
Newsletter
Blog
About us
Last forum posts
Home
::
Forums
::
Development
::
Symbian C++
User login
Username:
*
Password:
*
Create new account
Request new password
Featured pages
Configure your PC for Symbian development
Getting started with Symbian development
Symbian OS Error Codes
Common products UIDs
Nokia S60 SDK
Featured Software
NlMakesis
Y-Browser
Y-Tasks
Active users (last 30 days)
User
Score
Andreas
52
eric
51
rbrunner
42
alh
40
Bones
26
more
Feeds
More feeds...
Problem regarding HBufC
Login
to reply to this topic.
Mon, 2006-04-24 07:20
Amit Mahajan
Joined: 2006-04-08
Forum posts: 41
hi,
i want to receive data from socket by the following code.........
HBufC* ReadBuffer;
TPtr8 p=ReadBuffer->Des();
//Function is leaving at above statement.
iSocket.RecvFrom(p,anAddr,0,iStatus);
Can anyone suggest how to accomplish the above task.
Login
or
register
to post in forums
Mon, 2006-04-24 07:28
rbrunner
Joined: 2005-11-20
Forum posts: 1246
Re: Problem regarding HBufC
Merely declaring the HBufC is not enough. You have to allocate memory for it with NewL or NewLC.
René Brunner
 
Mon, 2006-04-24 07:29
max_i
Joined: 2005-08-11
Forum posts: 278
Re: Problem regarding HBufC
Hi Amit ,
you should allocate memory for your HBufC before you use it. like for example
HBufC* heapBuf = HBufC::NewL(10);
Please go through this link:
http://descriptors.blogspot.com/
for more information.
max_i
 
Mon, 2006-04-24 08:10
Amit Mahajan
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding HBufC
Sorry buddies,
I have already done NewL for HBufC. I give u the modified code:
HBufC* ReadBuffer=HBufC::NewL(500);
TPtr8 p=ReadBuffer->Des();
//Function is leaving at above statement.
iSocket.RecvFrom(p,anAddr,0,iStatus);
 
Mon, 2006-04-24 08:14
rbrunner
Joined: 2005-11-20
Forum posts: 1246
Re: Problem regarding HBufC
... so then the problem might be your mixup between 8 bit and 16 bit. HBufC is HBufC16, but you use a TPtr8. Try using HBufC8.
René Brunner
 
Mon, 2006-04-24 08:22
vivekchopra
Joined: 2005-03-15
Forum posts: 94
Re: Problem regarding HBufC
It doesn't even compile for me. Probably due to the TPtr8 usage. You should just leave it as TPtr or change the HBufC declaration also as HBufC8.
Vivek Chopra
Vivek Chopra
 
Mon, 2006-04-24 08:53
Amit Mahajan
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding HBufC
Quote from: rbrunner
... so then the problem might be your mixup between 8 bit and 16 bit. HBufC is HBufC16, but you use a TPtr8. Try using HBufC8.
I have used HBufC8.
 
Mon, 2006-04-24 08:59
Amit Mahajan
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding HBufC
Quote from: vivekchopra
It doesn't even compile for me. Probably due to the TPtr8 usage. You should just leave it as TPtr or change the HBufC declaration also as HBufC8.
Vivek Chopra
I have used HBufC8 n TPtr8, there is no problem of such kind.
 
Mon, 2006-04-24 09:14
max_i
Joined: 2005-08-11
Forum posts: 278
Re: Problem regarding HBufC
It should work. The below code works fine for me:
HBufC8* heapBuf = HBufC8::NewL(10);
TPtr8 p=heapBuf->Des();
Max_i
 
Mon, 2006-04-24 10:10
Amit Mahajan
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding HBufC
Quote from: max_i
It should work. The below code works fine for me:
HBufC8* heapBuf = HBufC8::NewL(10);
TPtr8 p=heapBuf->Des();
Max_i
It is still not working for me:
when i reach the line :
TPtr8 p=ReadBuffer->Des();
//Function is leaving at above statement.
Debugger gives the following msg at this line:
"Unhandled Exception in euser.dll:0xc0000005:access violation".
 
Mon, 2006-04-24 12:39
Amit Mahajan
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding HBufC
Thanx to all...
I have solved my problem with ur valuable suggestions.
Thanx & Regards,
Amit.
 
Login
to reply to this topic.
Forum posts: 1246
René Brunner
Forum posts: 278
you should allocate memory for your HBufC before you use it. like for example
HBufC* heapBuf = HBufC::NewL(10);
Please go through this link:
http://descriptors.blogspot.com/
for more information.
max_i
Forum posts: 41
I have already done NewL for HBufC. I give u the modified code:
HBufC* ReadBuffer=HBufC::NewL(500);
TPtr8 p=ReadBuffer->Des();
//Function is leaving at above statement.
iSocket.RecvFrom(p,anAddr,0,iStatus);
Forum posts: 1246
René Brunner
Forum posts: 94
Vivek Chopra
Vivek Chopra
Forum posts: 41
Forum posts: 41
Vivek Chopra
Forum posts: 278
HBufC8* heapBuf = HBufC8::NewL(10);
TPtr8 p=heapBuf->Des();
Max_i
Forum posts: 41
HBufC8* heapBuf = HBufC8::NewL(10);
TPtr8 p=heapBuf->Des();
Max_i
when i reach the line :
TPtr8 p=ReadBuffer->Des();
//Function is leaving at above statement.
Debugger gives the following msg at this line:
"Unhandled Exception in euser.dll:0xc0000005:access violation".
Forum posts: 41
I have solved my problem with ur valuable suggestions.
Thanx & Regards,
Amit.