Netty <===> NotNetty
Ioan Eugen Stan
stan.ieugen at gmail.com
Fri Oct 14 02:28:57 EDT 2011
2011/10/14 zx spectrum <webakaunt at gmail.com>:
> Is there anything specific that needs to be done when connecting a netty
> client to a non Netty server ( developed in some other language, etc.. )?
> Besides this:
> val bootstrap = new ClientBootstrap(
> new NioClientSocketChannelFactory(
> Executors.newCachedThreadPool,
> Executors.newCachedThreadPool ) )
> bootstrap.setPipelineFactory( new ChannelPipelineFactory {
> def getPipeline = {
> Channels.pipeline( channelHandlers.toArray : _* )
> }
> } )
> bootstrap.setOption( "remoteAddress", new InetSocketAddress( host, port
> ) )
> val channel = bootstrap.connect.getChannel // <= this succeeds
> clientChannel.write( ChannelBuffers.wrappedBuffer( message ) )
> It throws a NotYetConnected exception.
> If I do "clientChannel.write( ChannelBuffers.wrappedBuffer( message ), new
> InetSocketAddress( host, port ) )" instead, it throws a
> "java.net.ConnectException: connection timed out"
Netty is asynchronous and events based. This means that connect and
write functions return immediately you should catch the channel
Connected event and do your logic there.
Have you gone over the tutorial?
--
Ioan Eugen Stan
http://ieugen.blogspot.com/
More information about the netty-users
mailing list