Re: [Nioframework-discussion] Setting connection timeout
Brought to you by:
ronnystandtke
|
From: John P. <byh...@gm...> - 2009-10-10 20:30:48
|
Thanks. I had arrived at the same looking into the codebase. Thanks man. One question. If I try and make a connection to a non existent host, then I first get a java.net.NoRouteToHostException: No route to host exception and then shortly after a java.net.ConnectException: Connection timeout. In my code which is a blocking client to a MPD server, I already abort the operation to send some data to the server. My question is: is there something that I should do in connectFailed to clear any pending operations, so that when I next try a connection there is not some lingering state. John On Sat, Oct 10, 2009 at 12:13 PM, Ronny Standtke <Ron...@gm...>wrote: > Hi John > > > I've recently started back using the framework and is everthing is going > > ok, but I need to set the connection timeout and can't seem to get it > > right. > > Please take a look at the non-blocking example here: > http://nioframework.sourceforge.net/?q=node/12 > You can enforce a connection timeout by using the version of > registerClientSocketChannelHandler() with the timeout parameter (line 38 in > the example is without the timeout parameter). > > When you use the timeout parameter, the Dispatcher runs an internal > TimeoutHandler that calls ClientSocketChannelHandler.connectFailed() when > the > time runs out. > > > channel.socket().setSoTimeout(5000); > > This should not be necessary as all operations after connecting to the > socket > are non-blocking. > > Please let me know if this information was helpful for you. > > > P.S. The library looks like its coming on well. keep up the good work. > > Thanks! :-) > > Ronny > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Nioframework-discussion mailing list > Nio...@li... > https://lists.sourceforge.net/lists/listinfo/nioframework-discussion > |