I took your advice and pulled my streams up front. This did seem to
offer a small performance benefit, but the issue persists. I've
greatly simplified the reader function to ensure that there's nothing
stupid going on there causing the erratic behavior.

(defn connection-read [#^DataInputStream
conn]
  "reads data up to the amount specified by the packet
header"
  (let [bytes (make-array (. Byte TYPE)
4)]
    (. conn (read bytes 0
4))
    ; make an array big enough for header +
data
    (let [data (make-array (. Byte
TYPE)
                           (+ 4 (packet-length?
bytes)))]
      (System/arraycopy bytes 0 data 0
4)
      (. conn readFully data 4 (- (alength data)
4))
      ;(Thread/sleep 0) ; must uncomment for large
datasets
      data)))

I did some testing on my work PC today, and could not reproduce the
problem. I'm doing most of my dev on an old Powerbook G4 PPC running
OS X 10.5. I'm wondering if the issue could be related to the Java VM
on that machine, which is 1.5. There's no upgrade path to go beyond
1.5 on PPC, so unfortunately there's no way to tell.

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.
--~--~---------~--~----~------------~-------~--~----~
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