jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes java.nio and Selctor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.nio and Selctor" Watch "java.nio and Selctor" New topic

java.nio and Selctor

Andrew Mcmurray
Ranch Hand

Joined: Sep 24, 2005
Posts: 188
Hi all

I am trying to understand how java.nio with Async non blocking chanels. Basicly I am going to have to write a server that opens up a port and allows many different clients stream data to it to be processed. I have seen some examples, and I have gotton them to work some, but I want to understand what they are doing.

I understand that you set the channel up to the port you want to listen on, but I am not sure how the Selector and SelctorKeys work with it? Can anyone please explain at a high level how all of this is working?


Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Well, it appears to be a " static factory method " which I have heard so often, but wondered what they were talking about until the last few days when I had to figure it out because it has become time that I should grasp some fundamental java.security issues.

static ChannelIO getInstance(SocketChannel sc, boolean blocking)

will return a new'ed object, which must therefore be called in the run method of Acceptor - > which leads us directly into Servlets.

It may be that that is where your question should go, I started to read on Servlets and it is apparent that there is some code in the Servlet class that is implemented in the JVM and underlying interface code.

Message edit: I just found this: Saloon � Java � Sockets and Internet Protocols which may be even better.
[ September 18, 2007: Message edited by: Nicholas Jordan ]

"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
I agree. Here's the link: http://aspose.com/file-tools
subject: java.nio and Selctor
It's not a secret anymore!