Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: IdNNTP - 500 Error from Server

www.cryer.info
Managed Newsgroup Archive

Re: IdNNTP - 500 Error from Server

Subject:Re: IdNNTP - 500 Error from Server
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Thu, 22 Jun 2006 21:59:14

"Jack MacRank" <jack@macrank.com> wrote in message
news:449b737c$1@newsgroups.borland.com...

> Remy...don't freak out but I can't get the above code to work.

Sorry, my mistake.  I gave you code for Indy 9, not Indy 10.  The Indy 10
equivilent is as follows instead:

    uses
        IdGlobal, IdObjs, IdSys;

    procedure TfrmMain.btnPostClick(Sender: TObject);
    var
        postStream, partStream: TIdStream;

        procedure Msg(const ALine: string);
        begin
            WriteStringToStream(postStream, ALine);
            WriteStringToStream(postStream, EOL);
        end;

    begin
        postStream := TIdMemoryStream.Create;
        try
            Msg('From: Jack MacRank <jack@macrank.com>');
            Msg('Newsgroups: alt.binaries.test');
            Msg('Subject: CommandPost2 Test 22');
            Msg('Organization: None');
            Msg('X-Newsreader: CommandPost v2.00');
            Msg('');

            partStream :=
TIdReadFileExclusiveStream.Create('C:\odac7.exe.ntx');
            try
                postStream.CopyFrom(partStream, 0);
            finally
                Sys.FreeAndNil(partStream);
            end;

            postStream.Position := 0;

            nntp.Connect;
            try
                nntp.Post(postStream);
            finally
                nntp.Disconnect;
            end;
        finally
            Sys.FreeAndNil(postStream);
        end;
    end;


> Also, in your code "postStream.CopyFrom(partStream, 0);",
> why will 0 work instead of partStream.Size?

If you read the VCL documentation for CopyFrom(), you will see that 0 means
to copy the entire source stream.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive