Robin Mattheussen
2015-10-06 02:33:27 UTC
Hi,
I'm extremely new but very interested in developing in Clojure. I'm not a
professional, so please bear with me.
One of the first things I'm trying to do is getting an extremely simple TCP
server up and running with Aleph, but I don't quite understand the examples.
On GitHub, there is the following example:
(require '[aleph.tcp :as tcp])
(defn echo-handler [s info]
(s/connect s s))
(tcp/start-server echo-handler {:port 10001})
The *start-server* part is pretty obvious, and as far as I understand,
*s/connect* basically tells one stream to act as the source for another
stream which will act as a sink. So why are we directing the stream to
itself?
When I follow the link to more "complete" examples
<http://ideolalia.com/aleph/literate.html#aleph.examples.tcp>, it starts
off by immediately using Gloss, which is a little over my head. With this
example I don't even understand how I would go about logging incoming
messages to the console at the moment. Elaborating how I would go about
handling the stream, both in inspecting the content and transforming it,
would help me.
My use case is to take accept messages of unknown length from the clients,
transform said messages (which brings me to the question: can I map over a
stream?) and then ship them over to a queue to be handled by a different
part of the application. Very simple stuff really.
I'm extremely new but very interested in developing in Clojure. I'm not a
professional, so please bear with me.
One of the first things I'm trying to do is getting an extremely simple TCP
server up and running with Aleph, but I don't quite understand the examples.
On GitHub, there is the following example:
(require '[aleph.tcp :as tcp])
(defn echo-handler [s info]
(s/connect s s))
(tcp/start-server echo-handler {:port 10001})
The *start-server* part is pretty obvious, and as far as I understand,
*s/connect* basically tells one stream to act as the source for another
stream which will act as a sink. So why are we directing the stream to
itself?
When I follow the link to more "complete" examples
<http://ideolalia.com/aleph/literate.html#aleph.examples.tcp>, it starts
off by immediately using Gloss, which is a little over my head. With this
example I don't even understand how I would go about logging incoming
messages to the console at the moment. Elaborating how I would go about
handling the stream, both in inspecting the content and transforming it,
would help me.
My use case is to take accept messages of unknown length from the clients,
transform said messages (which brings me to the question: can I map over a
stream?) and then ship them over to a queue to be handled by a different
part of the application. Very simple stuff really.
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.