users@grizzly.java.net

How-to write a "Custom Protocol" using Grizzly

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 02 Jul 2008 21:57:21 -0400

Salut,

FYI those of you that want to start writing their own protocol on top of
Grizzly, I recommend you star looking at the following bundle:

http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-framework-samples/1.8.1

the src and the binaries are included. To test the binary, you can just
issue:

% java -jar grizzly-framework-samples-1.8.1.jar

And the Example_1 will be automatically executed.

This is a complete Client Server Example using a Custom Protocol build
with Grizzly Framework.

For a "silly" Demo see Example_1_Server.java and Example_1_Client.java

Behind the scenes a Custom Protocol is implemented which is a little bit
like GIOP (laugh just some ideas which led to
RequestMessage,ReplyMessage,FragmentMessage)

For Client Server Communication only one open Connection is needed. A
client inits a Connection (firewall friendly) but the server can send
messages at any time to any client.

All writes are done with AsyncWriter which means that always a full
message is send from Endpoint to Endpoint

But since Message Size is fixed 8192 bytes, bigger logical data gets
fragmented to FragmentMessages the Connection should be very responsive.

The fixed 8192 size also should be nice to memory when large data
amounts are send.

Have fun!

-- The Grizzly team