×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    51

    Question receiving in dynamic size

    Dear friends I try to make this solution for receiving in dynamic size
    By send the file size then the file but I have compilation error if u can help me on it I will be thank full to your time .

    iSendingSocket.Read(iBufferSize, iStatus);
    if(iBufferSize.Size() >0){
    TInt newSize;
    TLex8 lex(iBufferSize);
    lex.Val(newSize);
    TBuf8<newSize> buf; //<-----the error is her
    /*
    Template argument must be a constant expression in function
    */
    iSendingSocket.Read(buf, iStatus);

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    TBuf class needs to be defined size, so just change your code to use HBufC buffer class and you can define the size on run time. But remember that the buffer size will be at least the defined size, but can also be upto 3 bytes bigger (See SDK docs for more information)

    yucca

  3. #3
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    51
    Thank for your replay, but I try to read from socket
    And I can't use HBufC buffer as Parameters to Read(TDes8& aDesc,TRequestStatus& aStatus);and I try to use it as

    HBufC8 *buf;
    buf = HBufC8::NewL(newSize);
    socket.Read(buf->Des()); //compuler it is ok but it don't work
    if you have any solution?

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    you have to make the Tptr to be member variable of your class to make it work. If you just take it with Des() function, it is not valid for all of the active objects life time, so it will give you errors.

    yucca

  5. #5
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    51
    Dear friends
    I am not an expert in Symbian "( , what you mean of make the TPtr to be member variable of my class, I need to read from socket and save it in HBufC8, please can you explain how can I make it .

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    just have a member variable TPtr iBufPoint, declared in your class, then after constructing the HBufC buffer assign value to it: iBufPoint.Set(HbufBuffer->Des());, then pass the iBufPoint value to the function requiring it.

    then it should work, at least for that part.

    yucca

  7. #7
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    98

    Re: receiving in dynamic size

    Sorry, if it's a lame question, but how do you make a TPtr be a member variable? It doesn't have default constructor but it needs some initial target value (another TPtr or a TUint* pointer + size)?

    Thanks,
    Janos

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: receiving in dynamic size

    Quote Originally Posted by mrtj
    Sorry, if it's a lame question, but how do you make a TPtr be a member variable? It doesn't have default constructor but it needs some initial target value (another TPtr or a TUint* pointer + size)?
    When a member variable has no default constructor, it has to be initialized in every constructor of the containing class:
    Code:
    class CBarmi:public CBase
    {
    public:
        CBarmi(const TDesC &aText);
    private:
        const TDesC& iText;
    }
    
    CBarmi::CBarmi(const TDesC &aText):iText(aText)
    {
    }
    Although storing descriptor-references can be dangerous (this also applies for TPtr-s).

Posting Permissions

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