Board index » delphi » Threads and Indy v9 NNTP->GetBody

Threads and Indy v9 NNTP->GetBody

I'm using the NNTP component to retreive bodies of news articles. If I want
to download two or more articles simultaneously I guess I need to use
threads.

The GetBody function only returns once the whole body has been retrieved so
how is it supposed to be used in a thread?  Do I need to use one of the Indy
thread components, or something completely different?

Thanks in advance
Anthony

 

Re:Threads and Indy v9 NNTP->GetBody


Quote
"anthony" <anth...@nospam.com> wrote in message

news:3ed3f293$1@newsgroups.borland.com...

Quote
> The GetBody function only returns once
> the whole body has been retrieved

Correct.

Quote
> so how is it supposed to be used in a thread?

You would need to establish multiple connections to the server, one
connection per thread.

Gambit

Re:Threads and Indy v9 NNTP->GetBody


I don't know 100% for sure, but I believe that most NNTP servers do not
allow you to download multiple articles simultaneusly.

The only way I could think of is to actually have multiple connections to
the server, each connection in a VCL TThread object.  That way you can
download multiple articles simultaneously.

Again, this all depends on the server you are connecting to.

-Art

Quote
"anthony" <anth...@nospam.com> wrote in message

news:3ed3f293$1@newsgroups.borland.com...
Quote
> I'm using the NNTP component to retreive bodies of news articles. If I
want
> to download two or more articles simultaneously I guess I need to use
> threads.

> The GetBody function only returns once the whole body has been retrieved
so
> how is it supposed to be used in a thread?  Do I need to use one of the
Indy
> thread components, or something completely different?

> Thanks in advance
> Anthony

Re:Threads and Indy v9 NNTP->GetBody


"Chad Z. Hower aka Kudzu" <c...@hower.org> wrote in message
news:Xns9389E13BF9B11cpub@127.0.0.1...

Quote
> Many NNTP servers limit the number of simulteaneous
> connections per IP though, so watch out for connection refusals.

True enough.  That is why newsreaders that support multiple connections
usually provide an option to allow the user to specify the maximum number of
connections to make at a time :-)

Gambit

Re:Threads and Indy v9 NNTP->GetBody


"Remy Lebeau \(TeamB\)" <gambi...@yahoo.com> wrote in news:3ed3fd3c$1
@newsgroups.borland.com:

Quote
> You would need to establish multiple connections to the server, one
> connection per thread.

Many NNTP servers limit the number of simulteaneous connections per IP
though, so watch out for connection refusals.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want more Indy stuff? Try the Atozed Indy Portal at
        http://www.atozedsoftware.com/
    * More Free Demos
    * Free Articles
    * Extra Support

ELKNews - Get your free copy at http://www.atozedsoftware.com

Re:Threads and Indy v9 NNTP->GetBody


Yes I know about the limit of simultaneous connections. The server I want to
use accepts at least 4 connections.

Each connection is going to have its own thread, which will create its own
NNTP Client (TIdNNTP).
When I use MyNNTP = new TIdNNTP;  in the Execute function of TThread and
compile the project I get the error message,

[C++ Error] threads1.cpp(57): E2285 Could not find a match for
'TIdNNTP::TIdNNTP()'.

I have  TIdNNTP *MyNNTP;    in the private section of the TThread class.

Where am I going wrong?

The application is going to end up as console app so I don't want to start
dragging NNTP clients onto a form.

Thanks
Anthony

"Remy Lebeau (TeamB)" <gambi...@yahoo.com> wrote in message
news:3ed500b4$1@newsgroups.borland.com...

Quote

> "Chad Z. Hower aka Kudzu" <c...@hower.org> wrote in message
> news:Xns9389E13BF9B11cpub@127.0.0.1...

> > Many NNTP servers limit the number of simulteaneous
> > connections per IP though, so watch out for connection refusals.

> True enough.  That is why newsreaders that support multiple connections
> usually provide an option to allow the user to specify the maximum number
of
> connections to make at a time :-)

> Gambit

Re:Threads and Indy v9 NNTP->GetBody


Think I've sorted it,
changed
    MyNNTP = new TIdNNTP;
to
    MyNNTP = new TIdNNTP(NULL);

and it works.

Quote
"anthony" <anth...@nospam.com> wrote in message

news:3ed8bf6a$1@newsgroups.borland.com...
Quote
> Yes I know about the limit of simultaneous connections. The server I want
to
> use accepts at least 4 connections.

> Each connection is going to have its own thread, which will create its own
> NNTP Client (TIdNNTP).
> When I use MyNNTP = new TIdNNTP;  in the Execute function of TThread and
> compile the project I get the error message,

> [C++ Error] threads1.cpp(57): E2285 Could not find a match for
> 'TIdNNTP::TIdNNTP()'.

> I have  TIdNNTP *MyNNTP;    in the private section of the TThread class.

> Where am I going wrong?

> The application is going to end up as console app so I don't want to start
> dragging NNTP clients onto a form.

> Thanks
> Anthony

Re:Threads and Indy v9 NNTP->GetBody


Quote
"anthony" <anth...@nospam.com> wrote in message

news:3ed8bf6a$1@newsgroups.borland.com...

Quote
> When I use MyNNTP = new TIdNNTP;  in the
> Execute function of TThread and compile the
> project I get the error message,

> [C++ Error] threads1.cpp(57): E2285 Could not
> find a match for 'TIdNNTP::TIdNNTP()'.

You are trying to instantiate TIdNNTP using a default constructor, which it
does not have.  The actual constructor expects a TComponent* parameter.
Just pass it NULL.

    MyNNTP = new TIdNNTP(NULL);
    ...
    delete MyNNTP;

Gambit

Other Threads