Hi

I have the following scenario:

1. Peer A connects to Peer B.
2. Peer A sends Alive request to Peer B (once it is connected to Peer B).
3. Peer B replies Peer A with a Alive response.
4. For every specific interval, Peer A keep sending Peer B a Hello request.
    Peer B replies Peer A with a Hello response.


Here is what I implemented Peer A, for step 1 and 2:

NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
...
acceptor.bind(new InetSocketAddress(peerBPort));

// obtain a session in order to send the first Alive request
IoSession session = acceptor.newSession(new
InetSocketAddress(InetAddress.getByName(peerBIp), peerBPort), new
InetSocketAddress(peerAPort));
...
WriteFuture future = session.write(aliveRequest);
future.awaitUninterruptibly();


This program is working so far, but is this the correct way of doing thing?
Can we call newSession many times as we want?

I hope we can improve the javadoc of NioDatagramAcceptor, there is no
description for NioDatagramAcceptor.newSession().
See
http://mina.apache.org/report/trunk/apidocs/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.html


-- 

Hez

Reply via email to