John Caron wrote:
My application is a scientific data server that transfers large amounts of binary data. I am looking to make it as fast as possible and have been experimenting with the NIO FileChannel.transferTo() method. This appears to be much faster (3-10X) than using an OutputStream, under some circumstances. So I am trying to see if I can use this from within Tomcat.

So the question is whether there is a way to obtain a SocketChannel for the connection? The standard interface only allows to get an OutputStream. While Channels.newChannel(OutputStream out) gives a WriteableByteChannel, the transferTo() method does not work on it, apparently one needs to get the SocketChannel at a deeper level.

Has anyone else tried this? Any ideas would be much appreciated.
we haven't exposed the API at this level, since the data you write to the network, must go through several filters. you can still take advantage of the direct transfers by using Tomcat's built in send file technique.

A user previously wrote:

Any servlet can instruct Tomcat to perform a sendfile call by setting the appropriate response attributes. When using sendfile... * org.apache.tomcat.sendfile.filename: Canonical filename of the file which will be sent as a String
   * org.apache.tomcat.sendfile.start: Start offset as a Long
   * org.apache.tomcat.sendfile.end: End offset as a Long

So add these attributes into the request, (see DefaultServlet.java for an example), and if you are using the APR or the NIO connector in Tomcat, tomcat will transfer them directly

Filip


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to