users@grizzly.java.net

Re: Using Grizzly with hardware devices?

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 14 Oct 2008 10:38:35 -0400

Salut,

sorry for the delay, was on vacation :-)

P J wrote:
> RE: My question pertains to the use of the Grizzly Framework being used
> to communicate with hardware devices.
>
> Hello all,
>
> If this is not the correct way to ask questions, please direct me to the
> appropriate forum.
>
>
> Quick background:
>
> * The hardware devices are gprs modems, with embedded software(which
> I do not have code access to - so it's a constant) These modems
> are programmed to a very simple protocol, and can perform a few
> operations.
> * I am tasked to write a central server. The modems will poll my
> software, to which I will echo back... on occasion I will send
> through an operation request(self test, or parameter updates...)
> and of course receive "OKs" back.
> * My server application has to in JAVA.
> * At any point in time I might have to handle hundreds or even
> thousands of connections.
> * Using a blog example(Using Grizzly to read TCP Packets:
> <http://gallemore.blogspot.com/2007/07/using-grizzly-to-read-tcp-packets.html>http://gallemore.blogspot.com/2007/07/using-grizzly-to-read-tcp-packets.html)
> <http://gallemore.blogspot.com/2007/07/using-grizzly-to-read-tcp-packets.html>I
> got an echo server running successfully - qualify, I'm getting
> polling messages.
> <http://gallemore.blogspot.com/2007/07/using-grizzly-to-read-tcp-packets.html>
> * I'm a multiple threads programmer... learning the NIO ropes, this
> all is a bit different :-)
>
>
> My questions are as follow:
>
> 1. Would Grizzly be an appropriate technology for this type of
> application?

Yes.

> 2. It's so difficult to get relevant documentation. Are there any
> pdf's, e-books, printed books that would be beneficial to read?

Take a look at the following entries:

http://weblogs.java.net/blog/jfarcand/archive/2008/02/writing_a_tcpud_1.html
https://grizzly.dev.java.net/tutorials/tutorial-framework-filter-sample/index.html


> 3. I've tried expanding the example to use callbacks. (Reason: I
> might send a request to a modem 1, and whilst waiting for the
> response, need to tend to a polling message from modem 2, but once
> the reply-results arrive, I need to know that the message came
> from modem 1, because the message might not carry an identifying
> id - for example, an OK message has no modem ID - this of course
> is no problem with a 1-to-1 conversation,but with thousands it's a
> nightmare!) :-(

Can you elaborate on the above scenario? I would like to understand it
more...but should the protocol used between the server and the modem
include a special "header" that describe you is sending back the
response? Of you might use the IP address to detect from which modem the
response if from.

Quick question: are you defining the protocol between your server and
modem, or you already have a text/bytes protocol that you can't change?

A+

-- Jeanfrancois


>
>
> Kind Regards,
> Pete
>
>
>