anchor.diff:  
   |#
   
  -(defun jsocket-channel (jsocket)
  -  (jmethod-call jsocket ("getChannel")))
  -
  -(defun jselkey-channel (jselectionkey)
  -  (jmethod-call (jselectionkey "java.nio.channels.SelectionKey")
  -                ("channel")))
  -
   (defun op-read ()
  -  (java:jfield (java:jclass "java.nio.channels.SelectionKey")
  -               "OP_READ"))
  +  (jdi:do-jfield "java.nio.channels.SelectionKey"
  +                 "OP_READ"))
   
   (defun op-accept ()
  -  (java:jfield (java:jclass "java.nio.channels.SelectionKey")
  -               "OP_ACCEPT"))
  +  (jdi:do-jfield "java.nio.channels.SelectionKey"
  +                 "OP_ACCEPT"))
   
   (defun op-connect ()
  -  (java:jfield (java:jclass "java.nio.channels.SelectionKey")
  -               "OP_CONNECT"))
  +  (jdi:do-jfield "java.nio.channels.SelectionKey"
  +                 "OP_CONNECT"))
   
   (defun valid-ops (jchannel)
  -  (jmethod-call (jchannel "java.nio.channels.SelectableChannel")
  -                ("validOps")))
  -
  -(defun register (jchannel jselector ops)
  -  (jmethod-call (jchannel "java.nio.channels.SelectableChannel")
  -                ("register" "java.nio.channels.Selector" "int")
  -                jselector ops))
  -
  -(defun toggle-blocking (jchannel mode)
  -  (jmethod-call (jchannel "java.nio.channels.SelectableChannel")
  -                ("configureBlocking" "boolean")
  -                mode))
  -
  -(defun jselector-select (jselector timeout)
  -  (let ((to (truncate (* (or timeout 0) 1000))))
  -    (if (/= timeout 0)
  -        (jmethod-call (jselector "java.nio.channels.Selector")
  -                      ("select" "long") to)
  -      (jmethod-call (jselector "java.nio.channels.Selector")
  -                    ("selectNow")))))
  -
  -(defun jselector-selected-keys (jselector)
  -  (jmethod-call (jselector "java.nio.channels.Selector")
  -                ("selectedKeys")))
  -
  -(defun jset-iterator (jset)
  -  (jmethod-call (jset "java.util.Set") ("iterator")))
  -
  -(defun jiterator-has-next (jiterator)
  -  (jmethod-call (jiterator "java.util.Iterator") ("hasNext")))
  -
  -(defun jiterator-next (jiterator)
  -  (jmethod-call (jiterator "java.util.Iterator") ("next")))
  +  (jdi:do-jmethod-call jchannel "validOps"))
   
   (defun channel-class (jchannel)
     (let ((valid-ops (valid-ops jchannel)))
  
positive.code: 
  (defun wait-for-input-internal (sockets &key timeout)
    (let* ((ops (logior (op-read) (op-accept)))
           (selector (jstatic-call "java.nio.channels.Selector" ("open")))
           (channels
            (mapcar #'(lambda (s)
                        (jsocket-channel (socket s)))
                    sockets)))
      (unwind-protect
          (progn
            (let ((jfalse (java:make-immediate-object nil :boolean)))
              (dolist (channel channels)
                (toggle-blocking channel jfalse)
                (register channel selector (logand ops (valid-ops channel)))))
            (let ((ready-count
                   (jselector-select selector timeout)))
              (when (< 0 ready-count)
                ;; we actually have work to do
                (let* ((selkeys (jselector-selected-keys selector))
                       (selkey-iterator (jset-iterator selkeys))
                       ready-sockets)
                  (loop while (jiterator-has-next selkey-iterator)
                        do (let* ((key (jiterator-next selkey-iterator))
                                  (chan (jselkey-channel key)))
                             (push (jmethod-call (chan (channel-class chan))
                                                 ("socket"))
                                   ready-sockets)))
                  (print ready-sockets)
                  (print (remove-if #'(lambda (s)
                                        (not (member (socket s) ready-sockets
                                                     :test #'jequals)))
                                    sockets))))))
        ;; cancel all Selector registrations
        (let* ((keys (jmethod-call (selector "java.nio.channels.Selector")
                                   ("keys")))
               (iter (jset-iterator keys)))
          (loop while (jiterator-has-next iter)
                do (jmethod-call ((jiterator-next iter)
                                  "java.nio.channels.SelectionKey")
                                 ("cancel"))))
        ;; close the selectorx
        (jmethod-call (selector "java.nio.channels.Selector") ("close"))
        ;; make all sockets blocking again.
        (let ((jtrue (java:make-immediate-object t :boolean)))
          (dolist (chan channels)
            (toggle-blocking chan jtrue))))))
  
negative.code: (defun socket-connect (host port &key (element-type 'character))
    (let ((usock))
      (with-mapped-conditions (usock)
        (let* ((sock-addr (jdi:jcoerce
                           (jdi:do-jnew-call "java.net.InetSocketAddress"
                                             (host-to-hostname host)
                                             (jdi:jcoerce port :int))
                           "java.net.SocketAddress"))
               (jchan (jdi:do-jstatic-call "java.nio.channels.SocketChannel"
                                           "open" sock-addr))
               (sock (jdi:do-jmethod-call jchan "socket")))
          (describe sock)
           (setf usock
                 (make-stream-socket
                  :socket sock
                  :stream (ext:get-socket-stream (jdi:jop-deref sock)
                                                 :element-type element-type)))))))
  
  (defun socket-listen (host port
  