                         connect-ch (achan tn)
                         net (make-net tn listen-ch connect-ch)
                         connect-result-ch (achan tn)]
+                    ; Connecting to unlistened to port should fail.
                     (aput tn connect-ch [:addr-a 1000 :addr-x connect-result-ch])
                     (and (e n (atake tn connect-result-ch) nil nil)
                          (do (aclose tn listen-ch)

         (if (and (let [listen-ch (achan tn)
                        connect-ch (achan tn)
                        net (make-net tn listen-ch connect-ch)]
                    (aclose tn listen-ch) ; Closing listen-ch should shutdown net.
                    (e n (atake tn net) :done (atake tn net)))
                  (let [listen-ch (achan tn)
                        connect-ch (achan tn)
                        net (make-net tn listen-ch connect-ch)]
                    (aclose tn connect-ch) ; Closing connect-ch should shutdown net.
                    (e n (atake tn net) :done (atake tn net)))
                  (let [listen-ch (achan tn)
                        connect-ch (achan tn)
                        net (make-net tn listen-ch connect-ch)
                        accept-ch (achan tn)]
                    (aput tn listen-ch [:addr-a 1000 accept-ch])
                    (aclose tn listen-ch) ; Closing listen-ch should shutdown net and accept-ch's.
                    (and (e n (atake tn accept-ch) nil nil)
                         (e n (atake tn net) :done (atake tn net))))
                  (let [listen-ch (achan tn)
                        connect-ch (achan tn)
                        net (make-net tn listen-ch connect-ch)
                        accept-ch (achan tn)]
                    (aput tn listen-ch [:addr-a 1000 accept-ch])
                    (aclose tn connect-ch) ; Closing connect-ch should shutdown net and accept-ch's.
                    (and (e n (atake tn accept-ch) nil nil)
                         (e n (atake tn net) :done (atake tn net))))
                  (let [listen-ch (achan tn)

                        net (make-net tn listen-ch connect-ch)
                        accept-ch (achan tn)
                        accept-ch2 (achan tn)]
                    ; 2nd listen on same addr/port should fail.
                    (aput tn listen-ch [:addr-a 1000 accept-ch])
                    (aput tn listen-ch [:addr-a 1000 accept-ch2])
                    (and (e n (atake tn accept-ch2) nil nil)
                         (do (aclose tn listen-ch)
                             (aclose tn connect-ch)
