Connecting two server channels efficiently
Eric Bouer
ericbouer at gmail.com
Thu Apr 29 05:36:55 EDT 2010
On Thursday 29 April 2010 01:17:58 Johnny Luong wrote:
> beric wrote:
> > Hello list of a very nice project.
> > I'm trying to bridge two listening sockets so that any data on each of
> > them will reach the other. the UNIX way is: "cat fifo | nc -l -p 3344 |
> > nc -l -p 3355 > fifo" Now help me figure the Netty way :)
> >
> > My current way of doing that is by having 2 ServerBootstrap, while one of
> > them(foo) has a SimpleChannelUpstreamHandler that has access to the
> > pipeline of the other ServerBootstrap(bar) by holding a ChannelPiple
> > member.
> >
> > Then, in channelOpen I'm trying to add an OutboundHAndler(from
> > HexDumpProxy) to the channelpipeline of bar.
> >
> > It looks like this:
> > @Override
> >
> > public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent
> > e)
> >
> > throws Exception {
> >
> > //Suspend incoming traffic
> > final Channel inboundChannel = e.getChannel();
> > inboundChannel.setReadable(false);
> > this.sb2piChannelPipeline.addLast("handler-sb2", new
> >
> > OutboundHandler(e.getChannel()));
> >
> > }
> >
> > However I get a IllegalArgumentException : Duplicate handler name.
> > I guess I did something wrong. I would like to know why, or any (probably
> > better) alternative implementation of what I'm trying to do here.
> > Thanks.
>
> Would it make more sense just to have a ChannelGroup (add each new
> incoming channel to the set) for each listener and then within each
> handler, have it write to the appropriate channelgroup what that
> individual channel received?
>
> Best,
> Johnny
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
I'm not sure I'm right but if I'll write to that ChannelGroup you mentioned
I'll get an "echo" effect when data arrives . I don't want that.
Am I right ?
More information about the netty-users
mailing list