directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <trus...@gmail.com>
Subject Re: [Mina]How to build a synchronized client application based on MINA?
Date Mon, 25 Apr 2005 12:52:09 GMT
Hi Tang,

You don't need to use acceptor to build a client.  Acceptors are used
to build servers.You should use just a connector to create a client. 
Could you please refer to NetCat example?

Thanks,
Trustin

2005/4/25, Aaron Tang <gameplayers@gmail.com>:
> 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",ioThreadPoolFilter);
>        
> connector.getFilterChain().addFirst("threadPool",protocolThreadPoolFilter);
>         
>  
>         ProtocolSession session =
> connector.connect(remoteAddress,localAddress,provider);
>        
> session.write("004208010101000000000000000000000000000110");
>     }
> }


-- 
what we call human nature is actually human habit
--
http://gleamynode.net/

Mime
View raw message