Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Apr : Re: TidStreamVCL or TIdStreamVCLWin32???

www.cryer.info
Managed Newsgroup Archive

Re: TidStreamVCL or TIdStreamVCLWin32???

Subject:Re: TidStreamVCL or TIdStreamVCLWin32???
Posted by:"Jacques Noah" (jacques.no..@btinternet.com)
Date:Thu, 6 Apr 2006 23:51:45

Thank you for your reply, i still do not know what to leave out and what to
include when sending and recieving files through streams. basically i've got
a client server system(kind of a chat program), that i use to send files
with. Below is the code that used to work with the old indy10.0.52 version:

To recieve file(Server Code)
var
IdStream: TIdStreamVCL;
MStream: TMemoryStream;
begin
  MStream := TMemoryStream.Create;

        try
            IdStream := TIdStreamVCL.Create(MStream);
                  try
              AContext.Connection.IOHandler.ReadStream(IdStream);
                   mstream.SaveToFile(filename);
                         finally
                IdStream.Free;
            end;
           finally
            MStream.Free;
        end;
   end;
          ................................................

Send file(Client Code)
var
IdStream,idstream2: TIdStreamVCL;
MStream: TMemoryStream;
            ........................
FStream := TFileStream.Create(fn, fmOpenRead or fmShareDenyWrite);

        try
            IdStream := TIdStreamVCL.Create(fstream);
                    try
                Context.Connection.IOHandler.Write(IdStream, 0, True);
                Context.Connection.IOHandler.WriteLn('done!');
           finally
                IdStream.Free;
            end;
        finally
            FStream.Free;
        end;

Thank you for your help so far.


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:443568f9$1@newsgroups.borland.com...
>
> "Jacques Noah" <jacques.noah@btinternet.com> wrote in message
> news:4435561a$1@newsgroups.borland.com...
>
>> I just upgraded my app from indy10.0.52 to 10.1.5 and find that it
>> does not work anymore,because somehow the TidStreamVCL
>> does not contain the implementations that it used to have before.
>
> That is because Indy 10 underwent a large re-write awhile back to better
> address cross-platform issues.  The only reason TIdStreamVCL existed in
> the
> first place was to wrap the VCL's TStream class so it could be passed
> around
> Indy in a generic manner.  There were other wrapper classes available for
> platform-specific stream classes as well.  This is no longer the case.
> There are new IdSys and IdObjs units in the current Indy 10 build that
> abstract the platform-specific class and data types into generics that
> Indy
> uses everywhere now.  What this means is that wrapper classes are no
> longer
> needed.  For example, when working with VCL code, you can now pass TStream
> objects directly to Indy again without having to wrap them first.  When
> running under .NET code, .NET streams can be passed directly to Indy.  And
> so on for other platforms.
>
>> I'm usinfg streams to send files.
>
> You will have to re-write your code to get rid of TIdStreamVCL everywhere.
>
>> I've noticed that there is a TidStreamVCLWin32.pas
>
> Do not use the IdStream units directly.  They are only for Indy's internal
> use.
>
> As for TIdStreamVCLWin32.pas specifically, it is an obsolute file.
> TIdStreamVCLWin32 is not used anywhere.
>
>> All these errors are in the 'IdStreamRandomAccess.pas' file
>
> That is also an obsolete file.
>
>> Is there are alternative unit ican use with streams?
>
> Stop using wrappers and just pass your TStream objects directly now.
>
>
> Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive