Send bencode using BufferedOutputStream (#342)
This new implementation is faster because you only flush when you issue `.flush`, or until the buffer is full. Some simple experiments with Chlorine confirmed that small messages are being received in a whole block, instead of fragmented.
This commit is contained in:
parent
1c467080fa
commit
9f199ddef7
1 changed files with 3 additions and 2 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
[sci.impl.interpreter :refer [eval-string*]]
|
[sci.impl.interpreter :refer [eval-string*]]
|
||||||
[sci.impl.utils :as sci-utils]
|
[sci.impl.utils :as sci-utils]
|
||||||
[sci.impl.vars :as vars])
|
[sci.impl.vars :as vars])
|
||||||
(:import [java.io StringWriter OutputStream InputStream PushbackInputStream EOFException]
|
(:import [java.io StringWriter OutputStream InputStream PushbackInputStream EOFException BufferedOutputStream]
|
||||||
[java.net ServerSocket]))
|
[java.net ServerSocket]))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
@ -166,7 +166,8 @@
|
||||||
(let [client-socket (.accept listener)
|
(let [client-socket (.accept listener)
|
||||||
in (.getInputStream client-socket)
|
in (.getInputStream client-socket)
|
||||||
in (PushbackInputStream. in)
|
in (PushbackInputStream. in)
|
||||||
out (.getOutputStream client-socket)]
|
out (.getOutputStream client-socket)
|
||||||
|
out (BufferedOutputStream. out)]
|
||||||
(when @dev? (println "Connected."))
|
(when @dev? (println "Connected."))
|
||||||
(sci/future
|
(sci/future
|
||||||
(sci/binding
|
(sci/binding
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue