[prev in list] [next in list] [prev in thread] [next in thread]
List: spread-users
Subject: Re: [Spread-users] how to check for available messages
From: Taj Khattra <taj.khattra () pobox ! com>
Date: 2004-03-19 1:06:58
Message-ID: 20040319010658.GA21369 () localhost ! localdomain
[Download RAW message or body]
> like any other socket handle. There's also the SP_poll() function, but it's
> not particularly good even for polling because it doesn't return an error
> code if the client has gotten disconnected (it returns 0 then, so a "polling
> loop" just using SP_poll() will never know it if the client gets
> disconnected).
i modified my local copy of SP_poll() to work around this:
instead of returning the #bytes available with ioctl(), it returns
true/false by using a non-blocking select(). if the client gets
disconnected, select() returns readable but the next send() or
recv() will return -1 w/EPIPE.
FD_ZERO(&rset);
FD_SET(mbox, &rset);
tv.tv_sec = tv.tv_usec = 0;
ret = select(mbox+1, &rset, 0, 0, &tv);
if (ret < 0) return ILLEGAL_SESSION;
else return ret;
haven't noticed any problems so far...
_______________________________________________
Spread-users mailing list
Spread-users@lists.spread.org
http://lists.spread.org/mailman/listinfo/spread-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic