Re: Advice on implementing atomic read/write socket operations

2014-06-03 Thread Joachim De Beule
Thanks a lot Timothy! Unfortunately, I don't control the remote end, otherwise I would indeed use request ID's and core.async as you suggest. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.co

Re: Advice on implementing atomic read/write socket operations

2014-06-03 Thread Timothy Baldridge
" every write must be followed by a read before another write is performed." I won't assume for the moment that this is exactly what you need. If it is, disregard my reply. Another option is to simply use an agent to send data, and register callbacks in an atom. Each sent message gets an ID (auto

Re: Advice on implementing atomic read/write socket operations

2014-06-03 Thread Joachim De Beule
That's indeed what I needed! Thanks!! -- 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 unsubscrib

Re: Advice on implementing atomic read/write socket operations

2014-06-02 Thread James Reeves
Since two threads cannot use the connection concurrently, it sounds like you just need the locking macro: (locking conn (.write conn "blah") (.read conn)) - James On 2 June 2014 22:15, Joachim De Beule wrote: > Dear group, > > I have the following use case: I have a socket con

Advice on implementing atomic read/write socket operations

2014-06-02 Thread Joachim De Beule
Dear group, I have the following use case: I have a socket connection to an external service. I want several threads to use the same connection. Importantly, in order to get a synchronized response from the external service, every write must be followed by a read before another write is perfo