NIO Graphical Demos


The files in this area are graphical demos of some of the NIO APIs in action.

There are currently two demos here. Both of these are auto-run jars. There is no need to set the classpath. Just execute the command java -jar whatever.jar. All the needed classes are inside the jar files. Make sure your execution path points to a version of the 1.4 JDK. Preferably 1.4.1+.

Buffer Demo (bufferdemo.jar):

Displays the state of ByteBuffer and CharBuffer objects and presents the API calls as controls on the Window. Experiment and see how making changes to one buffer can affect other views of it.

The text entry widget for put() will recognize 0xnn notation for entering hex values. Strings longer than 1 will be executed as bulk puts.

The GUI representation of an array is poor, it's a simple string widget, but it illustrates how modifying an array changes the buffer view of it. There is currently no support for displaying or editing byte arrays. Maybe later.

Chat Server Select Demo (selectdemo.jar):

This demo displays the current state of a Selector object running inside a chat server. Click "Start Server" to start the server thread and then connect to the port it's listening on (default is 1234, can be overridden as a command line argument).

Use telnet to connect: 'telnet 127.0.0.1 1234' It works best if local echo is enabled and linemode is active (the default on linux and most flavors of Unix). As each connection is recieved, you will see it added to the Key Set, represented by rows in the table.

The GUI imposes an artificial slowdown on the selection process so you can see it step through the code. You can modify or disable the delay. You can also single-step through the code to examine it in detail.

The commands recognized by the chat protocol are displayed upon connection and can be listed again by entering '/help'.

The chat server enques outbound data on a per-channel basis and toggles interest in OP_WRITE to activate draining the output. Notice how the 'W' bit turns on and off in the Interest Set. Also notice that the values of the Ready Set are as-of the last return from Selector.select() and retain their old values while select() is sleeping. The Ready Set values only have meaning while the key is in the Selected Set.

Ron Hitchens
Tue Jun 17 00:38:13 PDT 2003


[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[   ]bufferdemo.jar16-Nov-2004 20:43 714K 
[   ]selectdemo.jar16-Nov-2004 20:51 1.0M 

Apache/2.2.15 (CentOS) Server at www.javanio.info Port 80