dev@grizzly.java.net

Re: NIO client support of Grizzly

From: Wang Yu <Wang.Yu_at_Sun.COM>
Date: Tue, 29 Sep 2009 09:35:30 +0800

Thanks a lot!

Best Regards
Wang Yu

Jeanfrancois Arcand wrote:
> Salut,
>
> Wang Yu wrote:
>> Hi, Jeanfrancois
>>
>> Thank you for your quick response. Some questions from me:
>> ----------------------------------------------------------------------------------
>>
>>
>> Controller controller = new Controller();
>> TCPSelectorHandler selectorHandler = new TCPSelectorHandler(true);
>> selectorHandler.setSelectionKeyHandler(new BaseSelectionKeyHandler());
>> controller.addSelectorHandler(selectorHandler);
>>
>> DefaultProtocolChain protocolChain = new DefaultProtocolChain();
>> protocolChain.addFilter(CustomProtocolParser.createParserProtocolFilter(
>> null); protocolChain.addFilter(new SampleDispatcher());
>>
>> TCPConnectorHandler connectorHandler1=(TCPConnectorHandler)
>> controller.acquireConnectorHandler(Controller.Protocol.TCP);
>> TCPConnectorHandler connectorHandler2=(TCPConnectorHandler)
>> controller.acquireConnectorHandler(Controller.Protocol.TCP);
>> TCPConnectorHandler connectorHandler3=(TCPConnectorHandler)
>> controller.acquireConnectorHandler(Controller.Protocol.TCP);
>>
>>
>> .
>> .
>> callbackHandler =new CallbackHandler {...};
>> connectorHandler1.connect(address1, callbackHandler,selectorHandler);
>> connectorHandler2.connect(address2, callbackHandler,selectorHandler);
>> connectorHandler3.connect(address3, callbackHandler,selectorHandler);
>>
>> ------------------------------------------------------------------------------------
>>
>>
>> Question1: Is it ok to get multiple ConnectorHandlers from the same
>> controller and connect to different addresses?
>
> Yes. Actually this is the optimal way for doing it.
>
>
>>
>> question2: Is callbackHandler threadsafe to be used in different
>> ConnectorHandlers?
>
> Is your CallbackHandler contains state (stateless or stateful)? If
> staeless you should be fine.
>
> Thanks
>
> -- Jeanfrancois
>
>
>>
>>
>> Thanks and best Regards
>> Wang yu
>>
>>
>>
>>
>> Jeanfrancois Arcand wrote:
>>> Salut
>>>
>>> Wang Yu wrote:
>>>> Hi,
>>>> Nonblocking sockets are usually thought of for server-side use.
>>>> But there can also be benefits to using one or a few sockets
>>>> in nonblocking mode on the client side.
>>>>
>>>> For example, with nonblocking sockets, an management console (by
>>>> using telnet protocol)
>>>> can carry on conversations with many servers simultaneously with a
>>>> few threads.
>>>>
>>>> Can Grizzly Framework support such programming mode (to be a telnet
>>>> client of hundreds of servers with only a few threads)?
>>>
>>> Yes, we support non blocking API via our ConnectorHandler API:
>>>
>>> * http://is.gd/3Bmum
>>>
>>> See an old tutorial on the topic here:
>>>
>>> * http://is.gd/3BmAZ
>>>
>>> Let us know how it goes.
>>>
>>> A+
>>>
>>> -- Jeanfrancois
>>>
>>>
>>>>
>>>> Thanks and Best Regards
>>>> Wang Yu
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>