Discussion:
Help on TCP example
craig worrall
2015-07-16 07:45:44 UTC
Permalink
Hi

I have the following code:

(ns fun
(:require
[manifold.deferred :as d]
[aleph.tcp :as tcp]))

(def port 19989)

(defn connect
[]
(println "CONNECT..")
(d/on-realized
(tcp/client {:host "localhost" :port port})
(fn [connection]
(println (str "connector succeeded " connection)))
(fn [failure-arg]
(println (str "connector failed " failure-arg))
(Thread/sleep 3000)
(connect))))

(defonce S
(tcp/start-server
(fn [arg1 arg2] (println (str "server accepted" arg1 "and" arg2)))
{:port port}))

and when I (connect), 2 connections are made to the server.

fun=> (connect)
CONNECT..
connector succeeded ***@42709226
<< 
 >>
server ***@6eee1e2and{:remote-addr
"127.0.0.1", :server-port 19989, :server-name "localhost"}
server ***@5c8049eband{:remote-addr
"127.0.0.1", :server-port 19989, :server-name "localhost"}

What have I done wrong here? Thanks!

Craig
--
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.
Zach Tellman
2015-07-16 21:32:06 UTC
Permalink
Hey Craig,

This is due to an issue in the macroexpansion of the :inline definition of
`on-realized`, which has since been fixed:
https://github.com/ztellman/manifold/commit/b80109d6d217fe85c8f2b412b1df74a3f02b6de1.
Targeting manifold `0.1.1-alpha3` will fix this for you. Sorry for the
confusion (it took me a while to figure out, too).

Zach

---------- Forwarded message ---------
From: craig worrall <***@transacumen.com>
Date: Thu, Jul 16, 2015 at 12:45 AM
Subject: Help on TCP example
To: <aleph-***@googlegroups.com>


Hi

I have the following code:

(ns fun
(:require
[manifold.deferred :as d]
[aleph.tcp :as tcp]))

(def port 19989)

(defn connect
[]
(println "CONNECT..")
(d/on-realized
(tcp/client {:host "localhost" :port port})
(fn [connection]
(println (str "connector succeeded " connection)))
(fn [failure-arg]
(println (str "connector failed " failure-arg))
(Thread/sleep 3000)
(connect))))

(defonce S
(tcp/start-server
(fn [arg1 arg2] (println (str "server accepted" arg1 "and" arg2)))
{:port port}))

and when I (connect), 2 connections are made to the server.

fun=> (connect)
CONNECT..
connector succeeded ***@42709226
<< 
 >>
server ***@6eee1e2and{:remote-addr
"127.0.0.1", :server-port 19989, :server-name "localhost"}
server ***@5c8049eband{:remote-addr
"127.0.0.1", :server-port 19989, :server-name "localhost"}

What have I done wrong here? Thanks!

Craig

--
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.
Loading...