29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
;;;; The zero-argument (agent/start): a program that names no socket at all.
|
|
;;;;
|
|
;;;; Under [flan dev] it binds where the daemon said, exactly as the explicit
|
|
;;;; form did, and nothing here can tell the difference. Run on its own — which
|
|
;;;; is what test_agent.ml does with it — it picks a path under TMPDIR and prints
|
|
;;;; it to stderr, and that printed line is the only way anything could connect.
|
|
;;;;
|
|
;;;; The second start is here to be a no-op. It answers 0 like the first, does
|
|
;;;; not bind a second socket, and does not print a second line; a program that
|
|
;;;; got its listener from somewhere else and also asks for one by hand is the
|
|
;;;; case that has to keep working.
|
|
(import agent "vendor:agent")
|
|
|
|
(defonce ticks i64)
|
|
|
|
(defn tick [] i64
|
|
(set ticks (+ ticks 1))
|
|
ticks)
|
|
|
|
(defn main [] i32
|
|
(if (< (agent/start) 0)
|
|
(do (println "cannot listen") 1)
|
|
(do
|
|
(print (agent/start)) (println "")
|
|
(print (tick)) (println "")
|
|
(while (= (agent/wait 100) 0) 0)
|
|
(print (tick)) (println "")
|
|
0)))
|