• Post Reply Bookmark Topic Watch Topic
  • New Topic

Channels & Selectors ??

 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having only really done I/O using java, I'm still fairly confused about these 2 entities.
It seems people with backgrounds such as C/C++ are familiar to this form of I/O.
Any good sources where I can find more sort of basic definitions about Channels, Selectors etc?
Thanks.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you'd posted this a day later, you'd be getting a chance to win Java NIO in our book giveaway. I recommend trying again; it's a good book. You may also want to check out a couple free articles from JavaWorld, here and here. Or ask more specific questions here.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
I have some knowledge of Selectors with reference to the POSIX select() function. Back in my old days of working on network apps in C; our programs needed to have access to several input streams. Since we do not know which stream will "suddenly" present itself with data; we needed a way to "block" on all the input streams at the same time. And select() will unblock when either of the streams has data to read. I'm quite sure that Java NIO's Selector concept is built upon POSIX's select() or poll() functions esp. on the Linux/Solaris/UNIX platforms.
Have a read of this article on Multiplex IO as implemented in Linux. It covers enough design issues to help you understand the concept of Selectors.
With regards to Channels; here's a good quote from this article:
Once you master Buffers and Channels, you've got the core of the new I/O APIs figured out. Buffers hold data, and Channels represent connections to data sources and consumers. These abstractions replace the need for you to do your own buffer management using byte arrays when reading from sockets or files. Channels can fill and drain Buffers.

Hope these help.
Pho
[ April 15, 2003: Message edited by: Pho Tek ]
 
Frank Zheng
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this link for a brief introduction of NIO:
NIO
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info and links guys.
James.
 
Ron Hitchens
Author
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, there's also my Java NIO book site.
Also, O'Reilly provides the Selector chapter of my book online with the catalog entry for my book.
If you still have specific questions, post them here and I'll try to answer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!