On Thu, 19 Feb 2009, Henry Rich wrote:
> I want to make socket_handler as lean as possible, so that students can 
> understand it.  My question is, When is socket_handler called, exactly? 
> In particular, if two sockets become ready, and socket_handler handles 
> only one, will it be called again when it completes?
> 
>  From my experimentation, it looks like socket_handler will be called 
> whenever there is any socket on the readable list.  It looks like 
> socket_handler is called only once when a socket goes on the writable 
> list, and I am guessing that it is called once whenever a socket goes 
> from notwritable to writable.  I don't know about errors, but I am 
> guessing that socket_handler is called whenever there is a socket on the 
> error list.
> 
> If all that is correct, then my socket_handler does not need to loop 
> internally for read and error processing: it can just take the first 
> ready socket and process that, knowing that it will be called again if 
> there is anything ready on another socket.
> 
> For writing, the appearance of a socket on the writable list indicates 
> that a connection has been completed or a queue-full condition has been 
> lifted.

I suppose you use the window sdasync extension. Your observation
should be correct.  It is edge trigger in that it will not trigger
again if you did not process that read/write that socket. It is more
robust to process all available read/write list inside a call.

The error list does not indicate error happened, but informs the arrival
of oob (out of bound) packets from the remote side.  Usually you do
not need to process it.

The sdasync actually provide information for the identification of
socket and the type of event.  If you process this message then it is
no need to do sdselect.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩313 王維  秋夜曲
    桂魄初生秋露微  輕羅已薄未更衣  銀箏夜久殷勤弄  心怯空房不忍歸
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to