public static void main(String[] args) throws IOException {

        SocketChannel channel = SocketChannel.open();
        channel.configureBlocking(false);
        //channel.connect(new InetSocketAddress("http://sinrs03064", 8080));
        channel.connect(new InetSocketAddress("11.169.114.250", 8080));

        Selector selector = Selector.open();
        System.out.println("open.");
        int interest = SelectionKey.OP_ACCEPT | SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE;
        SelectionKey key = channel.register(selector, interest);
        System.out.println("registered.");

        while(true) {

            int readyChannels = selector.select();

            System.out.println("selected.");

            if(readyChannels == 0) continue;

            System.out.println("looping.");

            Set<SelectionKey> selectedKeys = selector.selectedKeys();

            Iterator<SelectionKey> keyIterator = selectedKeys.iterator();

            while(keyIterator.hasNext()) {

                SelectionKey k = keyIterator.next();

                if(k.isAcceptable()) {
                    System.out.println("a connection was accepted by a ServerSocketChannel.");

                } else if (k.isConnectable()) {
                    System.out.println("a connection was established with a remote server.");

                } else if (k.isReadable()) {
                    System.out.println("// a channel is ready for reading");

                } else if (k.isWritable()) {
                    System.out.println("// a channel is ready for writing");
                }

                keyIterator.remove();
            }
        }
    }