On Tue, Jun 9, 2009 at 2:14 PM, gonzalo diethelm<[email protected]> wrote:
> I need to implement a class that will be able to passively listen on one
> (or maybe more) ports and, at the same time, actively connect to one or
> more processes running on other hosts and/or ports. It is clear that I
> would need to use the NioSocketAcceptor and NioSocketConnector classes,
> but it is not so clear how to issue the accept / connect calls. Can
> anybody suggest an example where I can see such behavior implemented?
>

Hi Gonzalo,

I've recently started building an nio application on top of MINA. I
found the following catered for pretty much everything I needed:

http://mina.apache.org/mina-v20-quick-start-guide.html <- shows using
NioSocketAcceptor/Connector.

http://mina.apache.org/tutorial-on-protocolcodecfilter-for-mina-2x.html
<- implemented custom protocol

http://mina.apache.org/report/trunk/xref/org/apache/mina/example/sumup/
<- using many Message types in the custom protocol (only AddMessage is
implemented but its pretty clear how to add more).

These are all linked from: http://mina.apache.org/documentation.html

>
>
> Can I listen on more than one port using a single instance of
> NioSocketAcceptor, or would I need to have multiple instances of
> NioSocketAcceptor in order to do this?
>

NioSocketAcceptor has bind(Iterable<? extends SocketAddress>) -
Javadoc suggests you'll listen on them all.

>
>
> What is the proper way of handling the case where a connect fails
> because the peer is not up yet, so I would like to retry the connection,
> maybe using some kind of exponential back off?
>

IoHandler might be the right place to look for this - it has an
ExceptionCaught method - you could catch the exception and change
values depending on what you want to do. I'm not entirely sure how to
make sure the reconnect from NioSocketConnector sets the reconnect
time based on your implementation.

>
>
> A more generic question: is there any documentation for developers using
> MINA? Or maybe a more complete example that could be helpful in showing
> recommended approaches?
>

I've linked those above. Be aware that MINA is very much work in
progress, the 2.0.0 branch is being updated a lot and much of the
documentation is in terms of examples and javadoc.

good luck :)

>
>
> Thanks and best regards,
>
>
>
> --
>
> Gonzalo Diethelm
>
> DCV - Chile
>
>
>
>
>
>
>



-- 
god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg

Reply via email to