Rick Hill wrote:

> "Darin Fisher" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 
>>> 2. Is the library multithreaded , i.e can we have multiple HTTP, FTP
>>> downloads at the same time.
>> 
>> 
>> portions of necko are multithreaded (thread-safe).  however, HTTP and
>> FTP currently are not thread-safe.  they expect to be called from one
>> thread.  this does not preclude having multiple HTTP and FTP downloads
>> at the same time, as all processing is event based.
>> 
>> take a look at the nsIChannel interface.  the method asyncRead triggers,
>> for example, an HTTP transaction.  data is fed chunk-by-chunk to the
>> caller via the nsIStreamListener interface passed to asyncRead.  the
>> listener's onDataAvailable method is called when a chunk of  data is
>> made available.  in this way clients of necko can process multiple
>> requests little by little in an asynchronous fashion.
>> 
>> ultimately, though, HTTP and probably FTP will be made thread-safe,
>> allowing separate threads to call asyncRead.
>> 
> 
> I have two questions with regarding your comments:
> 
> 1. Does nsIChannel represent a TCP-Connection ?  How to do multiple HTTP
> transactions through the same nsIChannel ?  What is the difference of the
> effect of multithreaded HTTP asyncRead and single thread nonblocking
> asynchronous HTTP transaction, does one download content faster than the
> other one.?

nsIChannel represents the logical connection to a resource identified by 
a URI.

You can read from a channel, which will retrieve the data associated 
with the channel's URI.
HTTP automatically tries to share/reuse server connections.

Currently, HTTP is not thread-safe, so you cannot call into HTTP from 
multiple threads.
This will hopefully change in the near future.

If all you care about is downloading content, you probably cannot do 
much better than a
single thread given that your network card is a serial device.  If you 
are doing a lot of work
processing the data from HTTP, then you would most likely want to hand 
the data off to
another thread.


> 
> 2. I tried to set the nsIStreamListener of the asyncRead as a parser with
> the following lines:
> 
>            nsCOMPtr<nsIParser> aParser;
>            nsComponentManager::CreateInstance(kParserCID, nsnull,
> kIParserIID,getter_AddRefs(aParser));
>         nsCOMPtr<nsIStreamListener> pListener(do_QueryInterface(aParser,
> &rv));
>         pChannel->AsyncRead(pListener,  info);
>         ...
> 
>     The program fails and gives the following error: "Error: Parser's
> IStreamListener API was not setup correctly in constructor."  Any suggestion
> for this ?


You should ask someone in the parser/layout world for help with this.

Darin

> 
> Thanks in advance for helps and comments.
> 
> 


Reply via email to