users@grizzly.java.net

Re: grizzly bug ? : TCPConnectorHandler.connect doesn't throw exception

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Mon, 05 Jan 2009 14:06:44 +0100

Hi Sebastien,

the IOException is not returned because connection is getting executed
asynchronously.
You can provide callback handler with following onConnect
implementation:

new CallbackHandler<Context>(){

             public void onConnect(IOEvent<Context> ioEvent) {
                 SelectionKey key =
ioEvent.attachment().getSelectionKey();
                 try{
                     tcpConnector.finishConnect(key);
                 } catch (IOException ex){
// Exceotion here!!!
                 }
                 ioEvent.attachment().getSelectorHandler().register(key,
                         SelectionKey.OP_READ);
             }

You can take a look at unit test TCPConnectorHandlerTest.

WBR,
Alexey.



On Dec 22, 2008, at 22:01 , Survivant 00 wrote:

> I'm trying to do a little test. A simple client that connect to a
> server and send data.. I try to connect to a server that isn't up..
> and I didn't receive a exception.. the program continue like
> everything is fine..
>
> try {
>
> f_controller = new Controller();
> f_tcpConnectorHandler = new TCPConnectorHandler();
>
> f_tcpConnectorHandler.connect(new
> InetSocketAddress("localhost", 7803));
>
> .....
>
> log4j:WARN No appenders could be found for logger
> (com.gfbn.quotegw.client.QuoteClientGrizzly).
> log4j:WARN Please initialize the log4j system properly.
> 2008-12-22 15:58:10 com.sun.grizzly.DefaultCallbackHandler onConnect
> GRAVE: Connection refused: no further information
>
>
> ....
>
> I was expecting a Exception at the line :
> f_tcpConnectorHandler.connect(new InetSocketAddress("localhost",
> 7803));
>
>
>