Hello,
What is REAL difference from communication point between MINA client
(IoConnector) and server (IoAcceptor)
They are both can send and receive data.
Maybe question is what server don't know where data should be send.
But in real situation, if server is smart and can send data when connection to
it established, then IoConnect becomes server?
Example:
First component:
IoConnector connector = new SocketConnector();
<set of filters here>
ConnectFuture connectFuture = connector.connect(getRemoteSocketAddress(), new
SomeIoHandler1());
connectFuture.join();
if (connectFuture.isConnected())
{
SocketAddress socketAddress = connectFuture.getSession().getLocalAddress();
IoAcceptor acceptor = new SocketAcceptor();
IoAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
((SocketAcceptorConfig) acceptorConfig).setReuseAddress(true);
((SocketAcceptorConfig) acceptorConfig).setDisconnectOnUnbind(false);
<set of filters here>
acceptor.bind(socketAddress, new SomeIoHandler2(), acceptorConfig);
}
Second component:
Usual server (but different from first component) with handler which will send
data on opening session event:
class SomeIoHandler3 extends IoHandlerAdapter
{
public void sessionOpened(IoSession session) throws Exception
{
WriteFuture writeFuture = session.write("<some data to send here>");
writeFuture.join();
}
}
And what happen with first component. Both handlers SomeIoHandler1 from client
and SomeIoHandler2 from server will receive data.
So who is client and who is server?
And how I can to do correct handling of such processes?
The main idea is to use the same channel for first component.
MINA: 1.1.7
JDK: 1.5
OS: Win, Unix
Thank you in advance.
-------------------------
Sergey Mamit'ko
ISD, http://www.isd.dp.ua/index.html.en