Yes ...

The client cannot connect/receive the server response...

-----------------------------------------------------------------------
SERVER SIDE:

public class MinaServer {

   private int port;

   public MinaServer(int port) throws IOException {
       this.port = port;
       bind();
   }

   private void bind() throws IOException {
       IoAcceptor acceptor = new SocketAcceptor();
       SocketAcceptorConfig config = new SocketAcceptorConfig();
       config.setReuseAddress(true);
       config.getFilterChain().addLast(
               "codec",
               new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                       .forName("UTF-8"))));
       TCPServiceProtocolHandler handler = new TCPServiceProtocolHandler();
       acceptor.bind(new InetSocketAddress(this.port), handler, config);
       LogFactory.getInstance().getLogger().info("Mina server started at
port " + this.port);
   }
}
-----------------------------------------------------------------------------------------------------------------

public class TCPServiceProtocolHandler extends IoHandlerAdapter {

   public void messageReceived(IoSession session, Object msg) throws
Exception {
       String message = msg.toString();
       Request request = new Request(message);
       String response = handleRequest(request);
       logger.debug("Response: " +response);
       session.write(actorResponse);
   }

   public void messageSent(IoSession session, Object msg) throws Exception
{
       super.messageSent(session, msg);
       logger.debug("Message " + msg + " sent.");
   }

  private String handleRequest(Request request){
      ...
  }

}
------------------------------------------------------------------

CLIENT SIDE:

public class SimpleMINAClient {
   public static void main(String[] args) {
       try {
           Socket socket = new Socket("localhost", 2500);
           OutputStream outputStream = socket.getOutputStream();
           PrintWriter out = new PrintWriter(outputStream);
           out.println("000000000003800||");
           out.flush();
           boolean socketClosed = socket.isClosed();
           sysout("Socket is closed?? " + socketClosed);
           if (!socketClosed) {
               InputStream in = socket.getInputStream();
               BufferedReader reader = new BufferedReader(
                       new InputStreamReader(in));
               String line = reader.readLine();
               sysout("Response from server: " + line);
               sysout("Socket is closed?? " + socket.isClosed());
           }
       } catch (UnknownHostException e) {
           e.printStackTrace();
       } catch (IOException e) {
           e.printStackTrace();
       }
   }
}





Any ideas???



On 11/7/06, Robert Greig <[EMAIL PROTECTED]> wrote:

On 07/11/06, David Borja <[EMAIL PROTECTED]> wrote:
> Exaclty!!!, i have a mina-server and i need to listen any socket-based
> client, not just java client!!!...

Yes that works. Have you tried it and are you experiencing a problem?

RG

Reply via email to