Salut,
Jeanfrancois Arcand wrote:
> Salut,
>
> forwarding to the proper list. Will reply from there :-)
>
> Thanks
>
> -- Jeanfrancois
>
> glassfish_at_javadesktop.org wrote:
>> Hi all,
>>
>> Not sure if this is the right place to post this message. I am new to
>> Java NIO (socket development to be exact) and read through Grizzly. I
>> always try to understand the underlying before picking a framework to
>> use.
>>
>> I am wonder if concurent read/write can be achieved with a single
>> thread which does the following:
>>
>> 1. create channel
>> 2. connect the channel
>> 3. create a selector
>> 4. register the selector to the channel
>> 5. set interest ops to OP_READ and OP_WRITE
>> 6. run in a loop to handle READ and WRITE
So far if I read you properly it will works, but any OP_READ/OP_WRITE
will block waiting for the previous one to be exectuted.
>> Besides, is it possible to write to channel.socket() directly without
>> going through selector. That is the loop in 6 above only handle READ
>> operation while calling a separate function in the same thread and
>> write to channel.socket().write(...)
Hum. Why would you write without a Selector. There is situation where
the write operation will return 0 (no bytes written) and you will need
to use a Selector (see [1]). The alternative is to use blocking socket :-)
Thanks
-- Jeanfrancois
[1]
http://weblogs.java.net/blog/jfarcand/archive/2006/05/tricks_and_tips_1.html
>>
>> Thanks!
>> [Message sent by forum member 'waikeichan' (waikeichan)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=297587
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>