On 9/5/11 2:04 PM, Antonio Rodriges wrote:
3) what would be better is to use a dedicated socket to send the data
to
the
remote peer (see FtpServer)
Is it really a good idea to open a dedicated socket for each client if
we have 1000+ clients?
Should not be an issue. Opening sockets is not costly, nor keeping them
opened.
Why is it better (separate sockets)? This scales well or performs well?
You have to do your homeworks here :)
Before I started experimenting with MIna I had no chance to work with
sockets nor read about programming them. So, if you have time it would
be kind of you to drop a couple of lines about it :)
What I meant here was that unless you bench your application, there is
no way for me to tell you what will be the best solution. Now, the
FtpServer uses a dedicated socket to transmit files to the client, so I
guess it's the way to go. But it depends on what you want to do. The
biggest advantage of having a dedicated socket is that you can do a
zero-copy transmission (ie you don't read the data in memory, copying it
into a buffer before sending it to the client. You just ask the
underlying system to directly read the data and send them into the socket).
(see http://www.ibm.com/developerworks/library/j-zerocopy/)
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com