Protocol implementation, Netty socket server, J2ME client

Nicholas Clare nickclare at gmail.com
Wed Apr 8 08:25:05 EDT 2009


Hi

A while ago I wrote server-side code to communicate with a J2ME
client. Looking back now, the way I did it was wrong, so here's what
I'd recommend for you: I'd use a simple binary protocol, that has a
message length field. So a frame could be something like this:

len (4 bytes) | message type (1 byte, or more, depending on what you
need) | your content

You can then use the LengthFieldBasedFrameDecoder class in Netty to do
your decoding on the server side. On the client side, it shouldn't be
too difficult to read in the length, and then read the rest of the
message. You can also make this extensible by having the server or
client ignore messages with a type it doesn't understand. So, for
example, text messages could be message type 1, pngs message type 2,
and so on.

As for security, I'm sorry, I'm not too knowledgeable about that, so
hopefully someone else can help you. I don't know what J2ME supports
in that area, but it might be possible to do some basic encryption.

I'm not really an expert, but I hope what I've suggested can maybe help you,
Nick

On Wed, Apr 8, 2009 at 2:09 PM, Karasko <karas at uralweb.ru> wrote:
>
> Hi, everyone.
> I am writing a sokcet server, using Netty, which would be serve a requests from
> J2ME devices (MIDP 2.0, CLDC). I am new person for networking, and concurrent programming,
> so any advice or critics is accepted.
>
> Typical request is to retrieve some data from SQL server, based on text query.
>
> Response could be a text of various lenght, or sometimes binary data (i.e. PNG image).
>
> Can you advise some prototype of simple protocol for this, which i can
> easily implement on client side J2ME device with standart packages:
>
> java.io.*;
> javax.microedition.io;
>
> I need protocol to be
> 1) extensible (adding new functionality doesn't require to rewrite code everywhere)
> 2) compact (less traffic is better)
> 3) secure (i don't know how to implement it yet, some advices will be nice)
>
>
> I also want to know how to send an PNG image (or whatever binary data) over socket connection from server..
> I think "new line" frame delimiter should be changed for smth else ?
>
> --
> View this message in context: http://n2.nabble.com/Protocol-implementation%2C-Netty-socket-server%2C-J2ME-client-tp2604867p2604867.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



More information about the netty-users mailing list