Server and Client at the same time

gonzalo diethelm gdiethelm at dcv.cl
Fri Jun 12 11:00:53 EDT 2009


Hi Trustin,

 

Thanks very much for your new Proxy example. I had taken some time yesterday to try and write what I was describing before (using the Telnet example as a basis); it will be very useful to me to compare it to what you wrote. I have several questions (and metaquestions) for now:

 

*         It would be great if the Java source code (like the link you provided) could be shown with syntax coloring and line numbers.

*         In your HexDumpProxy example, you only create a ServerBootstrap but do not create a ClientBootstrap; instead, you create the NioClientSocketChannelFactory “stand alone”. Then, within the HexDumpProxyInboundHandler you do create the ClientBootstrap. Why do you do it this way?

*         In the HexDumpProxyPipelineFactory you only add one handler (a HexDumpProxyInboundHandler) to the pipeline. Yesterday, with my own code, I tried doing this but got runtime exceptions indicating I could not cast a String to a ChannelBuffer. After looking more closely to the Telnet example, I decided to add three additional handlers before my own: a DelimiterBasedFrameDecoder, a StringDecoder and a StringEncoder. With that, my code worked fine, but I don't understand how you don't need those same handlers in the Proxy.

*         From what I understand, the OutboundHandler as implemented is receiving messages and sending them right back to the proxy. This caters to my “requirements”, but it might be clearer for a simple proxy example to just print out the received messages.

*         Other than the javadoc documentation, is there a good “manual for developers using Netty” anywhere? The user guide is very enlightening, but I am thinking more along the lines of architectural designs, patterns, when to use a class or another, etc.

 

Finally, for full disclosure: I posted a similar question (I mean my “requirements”) on the MINA mailing list. I know next to nothing about MINA and Netty, and am trying to compare them for my purposes.

 

Thanks again and best regards,


 

-- 

Gonzalo Diethelm

DCV - Chile

 

 

> -----Original Message-----

> From: netty-users-bounces at lists.jboss.org [mailto:netty-users-

> bounces at lists.jboss.org] On Behalf Of "??? (Trustin Lee)"

> Sent: Friday 12 Jun 2009 04:50

> To: netty-users at lists.jboss.org

> Subject: Re: Server and Client at the same time

> 

> Hi Gonzus,

> 

> I have been asked by many people about implementing such a proxy server,

> so I decided to write an example proxy server.  It's much easier to

> write an implementation than to explain how to do that, especially when

> it comes down to proxy server. :)

> 

> Check this out:

> 

> http://viewvc.jboss.org/cgi-

> bin/viewvc.cgi/netty/trunk/src/main/java/org/jboss/netty/example/proxy/

> 

> Shutting down is not very different from writing an ordinary server or

> client application.  Only one difference is that you need to shut down

> both client side and server side ChannelFactory at last.

> 

> HTH,

> Trustin

> 

> On 2009-06-11 오ネト 11:56, gonzus wrote:

> >

> > Hello everyone, this is my first post here. I am examining Netty (after

> a

> > brief look at MINA) and would like to gather opinions on how to

> implement a

> > proof of concept for my requirements.

> >

> > I intend to have two copies of the same program running on the same

> machine

> > (this is not a requirement, it is just easier). The two programs will be

> run

> > like this:

> >

> > $ program 8001 8002

> > $ program 8002 8001

> >

> > This means the first copy will bind on port 8001 and try to connect to

> port

> > 8002, and the second program will bind on port 8002 and try to connect

> to

> > port 8001. After successful connection, the program will send a single

> > string "Hello World"; after making sure it has sent one string and

> received

> > one string, the program will shut down gracefully.

> >

> > What I am trying to learn is how to do the following in Netty:

> >

> > 1. Have an acceptor and connector at the same time running on the same

> > program.

> > 2. Handle failed connect attempts and a reconnection policy.

> > 3. Proper way of shutting down a server.

> >

> > Are there any examples that could help me implement this? Any

> suggestions?

> >

> > Extra credit :-D if the program ends up being capable of running a

> single

> > copy like this and doing "the obvious":

> >

> > $ program 8003 8003

> >

> > Thanks in advance and best regards.

> 

> 

> --

> - Trustin Lee, http://gleamynode.net/

 



----------------------------------------- 
Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090612/64aa6740/attachment.html 


More information about the netty-users mailing list