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.configureBlo
cking(fals
e);
// Kick off connection establishment
socketChannel
.connect(new InetSocketAddress(this.hos
tAddress, 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(ne
w ChangeRequest(socketChanne
l,
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!
It is establishing a connection to the server.