Le 1/7/13 2:19 PM, Chad Beaulac a écrit :
> If you don't push the data onto a queue and wait for the selector to fire, 
> you could be trying to write data to a socket that is congestion controlled, 
> which you shouldn't do. The writer should wait for the selector to fire 
> saying the socket is writable before trying to write.

The thing is that in any case, we do try to write into the socket. If
the socket internal buffer gets full, we won't be able to write any ore
data into it, and we will have to wait for the socket to inform the
selector when it's ready to accept more data.

What I'm proposing is not any different, except that I bypass the queue
*if* and only *if* the socket is ready to accept new data. In other
words, the algorithm is :
  o if there is a queue containing messages waiting for the socket to be
ready (OP_WRITE set ti true), then enqueue the new message.
  o else try to write the message into the socket
    - if we can't write the full message, set the SelectionKey to be
interested in OP_WRITE, and enqueue the remaining data.
    - Otherwise, the data have already been written anyway, we are done

This is the way MINA 2 works since it's inception.

Is there anything wrong with that ?


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 

Reply via email to