                            server-send-ch (achan net)
                            server-recv-ch (achan net)]
                        ; TODO: Need to model connection delay and running out of ports.
+                       ; TODO: Need to model stop accepting connections / stop listening.
                        (aput net result-ch [client-send-ch client-recv-ch])
                        (aput net accept-ch [server-send-ch server-recv-ch])
                        (recur (inc ts) request-listen-ch request-connect-ch listens

(ns cbfg.net
  (:require-macros [cbfg.ago :refer [achan ago-loop aclose aalts aput]]))

(defn make-net [actx request-listen-ch request-connect-ch max-msgs-per-stream]
  (let [clean-up #()]

                                                         :to-side :send :to-addr to-addr :to-port to-port}))))
                     (do (aclose net result-ch)
                         (recur (inc ts) request-listen-ch request-connect-ch listens streams))))
                 (contains? sendables ch)
                 (let [send-ch ch]
                   (if-let [stream (get streams send-ch)]
                     (let [[msg result-ch] v]
                       (when result-ch
                         (aput-close net result-ch :ok))
                       (recur (inc ts) request-listen-ch request-connect-ch listens
                              (update-in streams [send-ch :msgs] conj msg)))
                     (recur (inc ts) request-listen-ch request-connect-ch listens
                            (dissoc streams send-ch)))) ; TODO: Handle closing recv-ch.
                 :else ; Must be completed delivery (recv).
                 (let [recv-ch ch
                       stream (first (filter #(= (:recv-ch %) recv-ch) (vals streams)))]
                   (recur (inc ts) request-listen-ch request-connect-ch listens
                          (dissoc streams (:send-ch stream)))))))))

