Re: clojure.lang.Atom cannot be cast to a java.lang.Num

2014-05-27 Thread Dylan Gleason
ppe. > Le 27 mai 2014 09:44, "Dylan Gleason" a écrit : > >> I am trying to read a TCP request via an instance of DataInputStream and >> am running into this error with the following code: >> >> (defn receive >> [socket] >> (with-open [reader

clojure.lang.Atom cannot be cast to a java.lang.Num

2014-05-27 Thread Dylan Gleason
I am trying to read a TCP request via an instance of DataInputStream and am running into this error with the following code: (defn receive [socket] (with-open [reader (DataInputStream. (.getInputStream socket))] (let [length (read-length reader) bytes-in (byte-array length)

Re: SocketError when using DataInputStream with Clojure TCP server

2014-05-24 Thread Dylan Gleason
Silly error -- I neglected to bind DataInputStream to the socket's input stream, i.e. (let [reader (DataInputStream. (.getInputStream socket))] ... ) On Thu, May 22, 2014 at 9:08 PM, Dylan Gleason wrote: > I am working with the TCP server example from the *Clojure Cookbook* to > cre

SocketError when using DataInputStream with Clojure TCP server

2014-05-22 Thread Dylan Gleason
I am working with the TCP server example from the *Clojure Cookbook* to create an echo server. I am trying to modify it so that the receive function uses a DataInputStream and reads the incoming request as a byte array. However, I am having difficulty getting it to work. Here is what I have so

Re: Asynchronous socket communication with agents

2014-05-15 Thread Dylan Gleason
if you're doing a blocking operation within the > function that handles the agent. > > I must admit I have no idea how the given code can yield inconsistent > results. Does anyone know if agents, like refs, call the given functions > speculatively? It would seem strange i

Asynchronous socket communication with agents

2014-05-14 Thread Dylan Gleason
I have a TCP socket connection in which I need to process several requests and conj each request and it's corresponding response to a vector for logging purposes. I need to transmit and receive via two asynchronous threads, where a transmit function is responsible for sending requests and a r

Clojure TCP client using Java Socket

2014-05-08 Thread Dylan Gleason
I am trying to write a TCP client in Clojure for a networking assignment. While everyone else is using C or C#, I elected to use Clojure and Java sockets, but am naturally running into problems and can't figure out for the life of me what I am doing wrong. The goal is to send a message to the i