directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Tang" <gameplay...@gmail.com>
Subject [Mina]How to build a synchronized client application based on MINA?
Date Mon, 25 Apr 2005 11:12:06 GMT
Hi all,
 
I wanna build a synchronized client application, i.e., client send a request
to server -> server send back its response
-> client get it! -> ...
 
I based my work on the reverser example, but my ACCEPTOR receive nothing:(,
but the server really send its response
back, which I can see with a network monitor app.
 
Please help by pointing out my misunderstanding and misusage of MINA!
 
This is my Main code, others is the same with reverser example.
 
public class Main
{
    private static final int PORT = 7910;
    private static final int LOCAL_PORT = 8888;
    private static final String HOST = "222.66.24.241";
 
    public static void main( String[] args ) throws Exception
    {
        // Create I/O and Protocol thread pool filter.
        // I/O thread pool performs encoding and decoding of messages.
        // Protocol thread pool performs actual protocol flow.
        IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
        ProtocolThreadPoolFilter protocolThreadPoolFilter = new
ProtocolThreadPoolFilter();
 
        // and start both.
        ioThreadPoolFilter.start();
        protocolThreadPoolFilter.start();
 
        InetSocketAddress localAddress = new InetSocketAddress(LOCAL_PORT);
        InetSocketAddress remoteAddress = new InetSocketAddress(HOST,PORT);
        ReverseProtocolProvider provider = new ReverseProtocolProvider();
        
        // Create a TCP/IP acceptor.
        IoProtocolAcceptor acceptor = new IoProtocolAcceptor(
                new SocketAcceptor() );
 
        // Add both thread pool filters.
        acceptor.getIoAcceptor().getFilterChain().addFirst(
                "threadPool", ioThreadPoolFilter );
        acceptor.getFilterChain().addFirst(
                "threadPool", protocolThreadPoolFilter );
 
        // Bind
        acceptor.bind( localAddress,provider );
 
        System.out.println( "Listening on port " + LOCAL_PORT );
        
        IoProtocolConnector connector = new IoProtocolConnector(new
SocketConnector());
 
connector.getIoConnector().getFilterChain().addFirst("threadPool",ioThreadPo
olFilter);
 
connector.getFilterChain().addFirst("threadPool",protocolThreadPoolFilter);
        
 
        ProtocolSession session =
connector.connect(remoteAddress,localAddress,provider);
        session.write("004208010101000000000000000000000000000110");
    }
}

Mime
View raw message