I don't know how relevant this is to what you're trying to do, but
I've recently written something that sounds like what you're doing. My
approach was to always send the size of the file (this involves
sending chunks of a file around) to the server before sending the
file. Since read() will block if there are no bytes to read, I wrap it
in a "dotimes":

(defn- transfer
 "Helper transfer routine."
 [#^InputStream from #^OutputStream to num-bytes]
 (let [arrsize 1024
       buff (make-array Byte/TYPE arrsize)
       loops (long (Math/ceil (/ num-bytes arrsize)))]
   (dotimes [i loops]
     (.read from buff)
     (.write to buff))))

I pre-calculate how many iterations of read/write I'll have to do up
front. This works for me.

On Mon, Jun 1, 2009 at 10:56 AM, tmountain <tinymount...@gmail.com> wrote:
>
> I'm not sure if that's related to the problem either, but it may very
> well improve performance. Thanks for the suggestion. I will try
> opening the streams ahead of time and see where that takes me.
>
> On Jun 1, 10:20 am, MikeM <michael.messini...@invista.com> wrote:
>> I don't know if this is part of the problem, but you appear to be
>> calling getInputStream repeatedly on the socket. I think more
>> typically the socket connnection is established, input and output
>> streams are obtained one time only, then the streams are used as
>> needed for the duration of the connection.
> >
>

--
Chris Wilson <christopher.j.wil...@gmail.com>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to