🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #290

Re: replacing ReadBuffer in Indy10

#290
From: Remy Lebeau (TeamB)
Date: Thu, 20 Mar 2008 16:43
44 lines
2190 bytes
"Dennis Cote" <denniscote@gmail.com> wrote in message 
news:47e28ff7$1@newsgroups.borland.com...

> is there a way to get Indy 10 to read directly into the existing char 
> buffer?

Indy does not support direct memory buffers anymore, by design.  One thing 
you can do, though, is derive a new class from TCustomMemoryStream that uses 
the char* buffer as its underlying memory block.  You could then use 
ReadStream() to receive the data directly into the buffer.  For example:

    class TBufferStream : public TCustomMemoryStream
    {
    public:
        __fastcall TBufferStream(void *Buffer, int Length)
            : TCustomMemoryStream()
        {
            SetPointer(Buffer, Length);
        }

        int __fastcall Write(void *Buffer, int Count)
        {
            Count = min(Count, Size-Position);
            if( Count > 0 )
            {
                memcpy(((LPBYTE)Memory) + Position, Buffer, Count);
                Seek(Count, soFromCurrent);
                return Count;
            }
            return 0;
        }
    };


    char* Buffer;
    int Length;
    ...
    TBufferStream *strm = new TBufferStream(Buffer, Length);
    IOHandler->ReadStream(strm, Length);
    delete strm;


Gambit 
Technical Details
Message-ID: <47e29429@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news2.arglkargh.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <47e28ff7$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b74f9f50d42f1dea
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <47e28ff7$1@newsgroups.borland.com>
Subject: Re: replacing ReadBuffer in Indy10
Date: Thu, 20 Mar 2008 09:43:28 -0700
Lines: 46
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
NNTP-Posting-Host: 207.178.157.90
Message-ID: <47e29429@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1206031401 207.178.157.90 (20 Mar 2008 09:43:21 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news2.arglkargh.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail