2007-02-25 (일), 02:42 +0800, mat 쓰시길:
> Thanks for your answer.
> 
> 1) My question is how to detect my write() is failed. MINA has this
> function?

If you write a message, IoSession.write() returns a WriteFuture.  You
can add a listener that handles an exception there.  You will also get
notified in your exceptionCaught() implementation.  A connection is
closed automatically when an IOException is caught, so you don't need to
do any further operation to close a connection.

> 2) Can you kindly show me how you generate your session ID? Right now i use
> session.hashcode, do you think it is good?

int sessionId = System.identityHashCode(session);

> 3) I am just newbie about the newworking programming. So can you point out
> the way to measure CPU time for  the I/O wait? What you said if my server
> side bandwidth is small, the situation I discribe could happen?

If you write faster than what your network can acceptor, MINA will store
your write requests in an internal queue.  If there are too many queued
requests, you will get OutOfMemoryError.  You need to control the write
throughput by yourself using methods such as
IoSession.getQueuedWriteReqeusts().

> 4) How can I prevent the client open millions of socket connection to my
> server and try to crash my server?

First, you need to be able to detect if the server is overloaded.  Once
detected, you can close any incoming connection or limit the number of
incoming messages by controlling the traffic of each session.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to