"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.?
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 ?
Thanks in advance for helps and comments.