void processSelectedKeys() throws IOException {
            for (Iterator i = sel.selectedKeys().iterator(); i.hasNext();) {

                // Retrieve the next key and remove it from the set
                SelectionKey sk = (SelectionKey)i.next();
                i.remove();

                // Retrieve the target and the channel
                Target t = (Target)sk.attachment();
                SocketChannel sc = (SocketChannel)sk.channel();

                // Attempt to complete the connection sequence
                try {
                    if (sc.finishConnect()) {
                        sk.cancel();
                        t.connectFinish = System.currentTimeMillis();
                        sc.close();
                        printer.add(t);
                    }
                } catch (IOException x) {
                    sc.close();
                    t.failure = x;
                    printer.add(t);
                }
            }
        }