I have a quite specific client-server design case and I want to ask for
suggestions. The task is about enhancing an existing system with new
functionality.
The system is composed of a server with public IP, 10 –
1000 CLDC clients with dynamic IP, and a device that
communicates with the server over the serial port (COM).
Client(J2ME):
Logs into the server and stays logged in, spontaneously asks
server for some data, but mainly waits for server requests. The client is
(probably, first thought) responsible for keeping the connection with server
alive.
Server (preferably windows, Java):
Waits for clients to
connect, stores and maintains all client connections (in case the server
wanted to send a request to the client, as clients have dynamic IP
addresses). The server stores data coming from the COM device. Waits for
requests from clients and provides them with desired (previously stored)
data. It also waits for COM device requests.
COM device:
Provides the server with
data (this is the data that clients spontaneously ask for). It also sends
requests (server should pass those requests to particular clients). The COM
device drives the whole system.
What I need to design is the server and software for clients. Serial device
is unchangeable.
Do you have any suggestions for the best approach here?
Regards!
J2ME
I have developed many systems involving J2ME and a backend. The one thing you need to watch out for is that the client connection that the server holds may not always be “open” because GPRS/3G is not very reliable (depending on the service provider/country). So you are right that the client is responsible for keeping the connection open.
Server
In general you can treat this like a normal multi threaded socket server.
On a windows system (assuming you programming in java) have a look at opening a java.io.File to a file name “COM1” in order to communicate with your serial device. This will make your life much easier instead of truing to do native serial communication.
It seems pretty straight forward so i am not sure what one can suggest.