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] Suggestions for a proxy server
Date Sun, 24 Apr 2005 13:01:16 GMT
Hi,

2005/4/24, Luca Zago <luca.zago@gmail.com>:
> Hi Guys,
> to understand how mina works, I am building a small proxy server, the
> functionality is quite easy, a client connect and send a message, the
> server broadcasts the message to all connected clients. I am facing
> two main problems:

It's a kind of chatroom server, right?

> 1) I don't understand if in mina there is a class which keeps all the
> opened session by an acceptor. And where I can manage the writing of
> the message in all the sessions opened?
> I was trying to keep the opened session in a vector inside my
> IoHandler class  and writing back the message in dataRead method to
> each session in the vector. But it doesn't seem a thread safe way of
> managing it.

There's no such class for now.  I think you're doing right.  I would
use Cursorable LinkedList from Jakarta Commons Collections which is
better when you iterate the list.

> 2) I  have a simple client to send a message, it looks client:
> wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
> wr.write("aString\n");
> wr.flush();
> wr.close();
> I run it many times..and on my server randomly I see my daRead method
> called, in the most of the times I see an opened and then immediately
> closed session. It seems it's too fast and the server looses the
> dataRead event. The server is built like the EchoServer in the
> example, with SocketAcceptor and IoThreadPoolFilter. Is it a problem
> of some configuration parameters?

Did you log any messages when server receives any data so that we can
confirm any data is lost?  If you didn't and just replied the data
back to client silently, The connection might be closed already when
you reply to client due to the sideeffect of thread pool.  Otherwise,
I'll test by myself, and try to reproduce this issue.  Of course any
test case code is appreciated.

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

Mime
View raw message