我已经向回显服务器发出了tcp请求,并希望从服务器获取回显消息,但是java.io/copy被阻止,直到服务器关闭客户端连接,我才能得到该消息吗?
(defn send-request
"Sends an HTTP GET request to the specified host, port, and path"
[host port path]
(with-open [sock (Socket. host port)
writer (io/writer sock)
reader (io/reader sock)
response (StringWriter.)]
(.append writer (str "jeff-test"))
(.flush writer)
; block here till server close the connection
(io/copy reader response)
(println (slurp reader))
(println "end read\n")))
(str response)
(println response)))