Re: PR_Poll() and non-blocking sockets?

"Wan-Teh Chang" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
On Wed, Jul 30, 2008 at 3:01 PM, Matt Lawson <[email protected]> wrote:
>
> OK I wrote a simplified program, but this one works as expected!  It seems the problem in my main application was that I was confusing the various sockets.  The poll would trigger on one, but then I would inadvertently read a different one, so the first one's data was still there, that's why it triggered every time.
>
> Sorry to waste your time.  I have included the sample program in hopes that it may help someone else.

Thanks for the test program.  I took a quick look at the portions of it
that use PR_Poll.  I'd like to suggest some changes:

1. Add a 'break' statement, after the printf statement, for the case
-1 in the switch statement.

2. In the default case, don't call PR_Available.  Just call PR_Recv
directly.  If PR_Recv
returns 0, it means end of stream.

3. As you noted, you should scan through pollArray, and check their
out_flags field to
decide what you should do about each socket.

Wan-Teh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.