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 17:20:40

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

> Probably the IdNNTP.Post()?

Probably?  I did ask you to show more of the communication.  What commands
are you sending before receiving the 240 response?

> Here is some more of the sniffer output:
<snip>
> Here is my code for the test posting:

Your code is adding a "." at the end of the message.  Do not do that!
Post() writes a terminating "." to the socket after sending the message
data.  As such, you are actually sending an extra command to the server.
The 240 is in response to the first "." from your data, then the 500 is
coming from the second "." that Post() sends.  Disconnect() is then
receiving that 500 response and the 205 remains in the socket unread.

Use this code instead:

    procedure TfrmMain.btnPostClick(Sender: TObject);
    var
        postStream: TMemoryStream;
        partStream: TFileStream;
    begin
        postStream := TMemoryStream.Create;
        try
            with TIdStream(postStream) do
            begin
                WriteLn('From: Jack MacRank <jack@macrank.com>');
                WriteLn('Newsgroups: alt.binaries.test');
                WriteLn('Subject: CommandPost2 Test 22');
                WriteLn('Organization: None');
                WriteLn('X-Newsreader: CommandPost v2.00');
                WriteLn;
            end;

            partStream := TFileStream.Create('C:\odac7.exe.ntx', fmOpenRead
or fmShareDenyNone);
            try
                postStream.CopyFrom(partStream, 0);
            finally
                partStream.Free;
            end;

            postStream.Position := 0;

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


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive