Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 6370 invoked from network); 10 Feb 2008 22:45:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Feb 2008 22:45:33 -0000 Received: (qmail 56172 invoked by uid 500); 10 Feb 2008 22:45:14 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 56150 invoked by uid 500); 10 Feb 2008 22:45:14 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 56139 invoked by uid 99); 10 Feb 2008 22:45:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Feb 2008 14:45:14 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of caron@unidata.ucar.edu designates 128.117.140.62 as permitted sender) Received: from [128.117.140.62] (HELO laraine.unidata.ucar.edu) (128.117.140.62) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Feb 2008 22:44:43 +0000 Received: from [128.117.140.71] (bert.unidata.ucar.edu [128.117.140.71]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "John Caron", Issuer "mailhost.unidata.ucar.edu" (verified OK)) by laraine.unidata.ucar.edu (Postfix) with ESMTP id BEE1BCB188 for ; Sun, 10 Feb 2008 15:44:50 -0700 (MST) Message-ID: <47AF7E61.6060109@unidata.ucar.edu> Date: Sun, 10 Feb 2008 15:44:49 -0700 From: John Caron User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Obtain a SocketChannel instead of OutputStream ? References: <47A87F2D.1070909@unidata.ucar.edu> <47A88A95.2020509@hanik.com> In-Reply-To: <47A88A95.2020509@hanik.com> X-Enigmail-Version: 0.95.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Filip Hanik - Dev Lists wrote: > 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 Hi Filip: I may need to make many such transfers to satisfy the request, so sendfile doesnt seem like it will work. I realize this would bypass the Filters. Perhaps its not worth it, but I would like to test the possible performance gain. Thanks for the help.... John --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org