×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    Extract portion of hbuc8

    hi,

    I have a problem extracting some byte from an HBufC8 buffer.

    when i call "mybuffer->mid(2,1)" my appl crash!!!!!!!!!!
    ps. i use series 60 emulator for 6630

    the code:
    ...
    HBufC8* iBuffer2 = HBufC8::NewL(333);
    TPtr8 auxPtr(( TUint8* )iBuffer2->Des().Ptr(), 332);
    iBufferPtr.Set( auxPtr );
    iSocket.RecvFrom( iBufferPtr ,remoteAddress,0,iStatus);

    TPtrC8 ptr = buffer->Mid(2,1);
    TUint tmpInt;
    TLex8 lex(ptr);
    lex.Val(tmpInt); // tmpInt is now 123

    m.AppendNum(tmpInt);
    m.Append("some text");
    ShowMessage(m, ETrue); //other function
    ...

    tanks

  2. #2
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    correct code: Extract portion of hbuc8

    HBufC8* buffer = HBufC8::NewL(333);
    TPtr8 auxPtr(( TUint8* )buffer->Des().Ptr(), 332);
    iBufferPtr.Set( auxPtr );
    iSocket.RecvFrom( iBufferPtr ,remoteAddress,0,iStatus);

    TPtrC8 ptr = buffer->Mid(2,1);
    TUint tmpInt;
    TLex8 lex(ptr);
    lex.Val(tmpInt); // tmpInt is now 123

    m.AppendNum(tmpInt);
    m.Append("some text");
    ShowMessage(m, ETrue); //other functio

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    61

    Re: Extract portion of hbuc8

    After

    Code:
    iSocket.RecvFrom( iBufferPtr ,remoteAddress,0,iStatus);
    You should wait for the async request to end before trying to read the buffer. Now you do not wait but continue directly to handling the buffer, even though nothing has been received. Either put all thisn inside an active object or call User::WaitForRequest after calling RecvFrom. If you use the AO way, make sure anything you pass to async methods is a member variable, not an automatic variable.

    Furthermore, you do not check how much data was actually received.

Similar Threads

  1. Replies: 2
    Last Post: 2006-01-22, 18:00
  2. Symbian C++ - Series 60 - How can i extract details for an SMS message?
    By periakaruppan in forum Symbian User Interface
    Replies: 2
    Last Post: 2005-09-05, 07:40
  3. Replies: 4
    Last Post: 2005-08-03, 11:21
  4. Symbian C++ - Series 60 - How can i extract details for an SMS message?
    By periakaruppan in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-08-03, 02:18
  5. Symbian C++ - Series 60 - How can i extract details for an SMS message?
    By periakaruppan in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2005-08-02, 10:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×