William Bardwell wrote:
I am trying to write some standalone necko code, but am having
trouble figuring out how one is supposed to use sockets in an
async manner.
Currently I am doing:
a SocketTransportServer -> CreateTransport
And then doing
transport->OpenInputStream
then NS_NewInputStreamPump,
and then
pump->AsyncRead (with my listener)
but I end up getting
ssertion failure: PR_CLIST_IS_EMPTY(&self->link), at mozilla/xpcom/threads/plevent.c:697
After doing a Read of the size passed in to the OnDataAvailable
routine in the listener.


How should I be doing async reads on a socket?
(Should I be trying to write stuff to nsIAsyncInputStream/nsIAsyncOutputStream, which the
socket streams seem to be, although the interfaces don't
say that (so I guess you have to query the streams for
that interface.))


Similarly, I was thinking of using NS_BackgroundOutputStream to
handle my output to the socket, but now I am doubting that
theory.  What should I do to do async output (I don't need to
keep track of what data was sent when, I just need it to go out
whenever the socket will take it.)



have you created a nsIEventQueue for the thread which calls AsyncRead?
to do async i/o with the socket transport service, it is not strictly
required that you have a nsIEventQueue, but nsInputStreamPump does
expect it to exist.  please see sample code in TestProtocols.cpp for
an example of how to setup a nsIEventQueue.

darin




Reply via email to