On Jan 29, 2008 2:58 AM, Jeff Walden <[EMAIL PROTECTED]> wrote:
> I'm not even sure why it works with the alert.  I'd think unconditionally 
> reading 512 bytes from the stream every time around the loop is bad, because 
> you have no guarantee that that many bytes are available (you only know at 
> least one byte's available), and since you've opened the stream in blocking 
> mode it's going to sit there until 512 bytes can be read or the connection is 
> closed -- but then your writes to the output stream will fail.
>
> Jeff
>
Thanks, but...
originally I used "is . available ( )" (where "is" is of type
nsIInputStream) instead of 512, with the same problem (with alert it
works, whitout alert it does not). By the way, the read function takes
as paramenter the maximun number of bytes to read, if the stream ends
first, it is going to read until the last byte, not more (that is way
the available method let you know if still there is something else in
the stream). [1]
I think the problem is in the way the net lib used the thread and/or
the event queue (that the alert fix in some way), but neither I am not
sure nor I do not know so much about that.

[1] 
http://www.xulplanet.com/references/xpcomref/ifaces/nsIScriptableInputStream.htm
and 
http://www.xulplanet.com/references/xpcomref/ifaces/nsIScriptableInputStream.html
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network

Reply via email to