troubleshooting Question

question on a nio example (1)

Avatar of matthew016
matthew016Flag for Belgium asked on
Java
14 Comments1 Solution223 ViewsLast Modified:
Hi,

This is the tutorial I try to fully understand:
http://rox-xmlrpc.sourceforge.net/niotut/index.html
(I may ask several questions about this tutorial)

I understand the whole sever-side code, but I don't understand the logic client-side.
Firstly, this part :

private SocketChannel initiateConnection() throws IOException {
      // Create a non-blocking socket channel
      SocketChannel socketChannel = SocketChannel.open();
      socketChannel.configureBlocking(false);

      // Kick off connection establishment
      socketChannel
                  .connect(new InetSocketAddress(this.hostAddress, this.port));

      // Queue a channel registration since the caller is not the
      // selecting thread. As part of the registration we'll register
      // an interest in connection events. These are raised when a channel
      // is ready to complete connection establishment.
      synchronized (this.pendingChanges) {
            this.pendingChanges.add(new ChangeRequest(socketChannel,
                        ChangeRequest.REGISTER, SelectionKey.OP_CONNECT));
      }

      return socketChannel;
}

and the paragraph below (not any of these sentences, explain all of them please in a more simple way).

Thanks for the help!
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros