Client Server like program, which way is better?

K

Kevin

Sorry I am really new to "network" things. :-D

There is a task like:
previously, the program does a lot of IO and calculation and shows them
out. All on the same machine in one piece code. Since the IO and
calculation is very very time (and memory) consuming, now it is asked
the possibility of doing it in the "client-server" way:

So I hope it can work like this:
1) client sends server of "job ABC": which files to load and how to
calculate them and where to save them. Please note the files are never
transfered over the network. They are always read/saved on the server
side.
2) server side does the job (IO, calculation) and when done, sends
something back to the client to inform the client "job ABC is done".
3) then the client can retrieve the results from server for display.
(The results are just some numbers so should be fast over the network).

For this application, which architecture / packages / classes should we
use? It would be very useful if someone can write a "pseudo" code so
that I can know which methods to use are best in terms of efficiency as
well as easy to code. And a set of keywords so that I can google them
for the details. Also, is the simple examples from sun's site:
http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
good for real applications such as the one I need? (I am guessing a lot
of "hello world" applcations are really not that good in real world)

As the above task, any pitfalls, shortcuts, known bugs or issues, or
anything else that should pay special attention?

Thank you a lot!
 
J

Jean-Paul

Definitely,

sockets are the way to go here. Also, because you really don't want to
be reworking your program everytime the server address changes and so
on, make sure that you have a configuration file (maybe using XML)
where users can just change server host, ports and so on. This makes
your program more dynamic and easy to adapt when say, the server
environment is changed or any event like that occurs.
 
F

frankgerlach

Maybe it's overkill, but you should also consider technologies such as
CORBA, RMI or SimpleORB. These technologies provide mechanisms to
transport data structures over the network (aka Marshalling or
Serialization). They also handle things like thread creation.
 
J

jlp

(e-mail address removed) a écrit :
Maybe it's overkill, but you should also consider technologies such as
CORBA, RMI or SimpleORB. These technologies provide mechanisms to
transport data structures over the network (aka Marshalling or
Serialization). They also handle things like thread creation.
and WebServices / SOAP ;-)
 
J

jlp

Kevin a écrit :
Sorry I am really new to "network" things. :-D

There is a task like:
previously, the program does a lot of IO and calculation and shows them
out. All on the same machine in one piece code. Since the IO and
calculation is very very time (and memory) consuming, now it is asked
the possibility of doing it in the "client-server" way:

So I hope it can work like this:
1) client sends server of "job ABC": which files to load and how to
calculate them and where to save them. Please note the files are never
transfered over the network. They are always read/saved on the server
side.
2) server side does the job (IO, calculation) and when done, sends
something back to the client to inform the client "job ABC is done".
3) then the client can retrieve the results from server for display.
(The results are just some numbers so should be fast over the network).

For this application, which architecture / packages / classes should we
use? It would be very useful if someone can write a "pseudo" code so
that I can know which methods to use are best in terms of efficiency as
well as easy to code. And a set of keywords so that I can google them
for the details. Also, is the simple examples from sun's site:
http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
good for real applications such as the one I need? (I am guessing a lot
of "hello world" applcations are really not that good in real world)

As the above task, any pitfalls, shortcuts, known bugs or issues, or
anything else that should pay special attention?

Thank you a lot!
For good examples of Client/server with sockets look at Bruce Eckel's
book "Thinking in Java third edition " available in pdf on the net.
here for example : http://www.codeguru.com/java/tij/
the 4th edition will be available soon, but it will not be free ...
 
P

Patrick May

Kevin said:
There is a task like:
previously, the program does a lot of IO and calculation and shows
them out. All on the same machine in one piece code. Since the IO
and calculation is very very time (and memory) consuming, now it is
asked the possibility of doing it in the "client-server" way:

So I hope it can work like this:
1) client sends server of "job ABC": which files to load and how to
calculate them and where to save them. Please note the files are
never transfered over the network. They are always read/saved on the
server side.
2) server side does the job (IO, calculation) and when done, sends
something back to the client to inform the client "job ABC is done".
3) then the client can retrieve the results from server for display.
(The results are just some numbers so should be fast over the
network).

This is a classic set of requirements addressed by the
master/worker pattern communicating via a JavaSpace. Two articles
that explain this are:

http://www.javaworld.com/javaworld/jw-01-2000/jw-01-jiniology.html
http://www.javaworld.com/javaworld/jw-06-2000/jw-0623-jiniology.html

Also, see http://www.jini.org for general Jini concepts.

Regards,

Patrick
 
K

Kevin

Thanks to all.

I think I will try the sockets for fast start.
Also, Java space looks like exactly what I want. But it seems a little
bit complex for me (I never use Jini before). I will take a close look.

Also thanks for all the resourceful URLs. :)
 
N

Nigel Wade

Kevin said:
Sorry I am really new to "network" things. :-D

There is a task like:
previously, the program does a lot of IO and calculation and shows them
out. All on the same machine in one piece code. Since the IO and
calculation is very very time (and memory) consuming, now it is asked
the possibility of doing it in the "client-server" way:

So I hope it can work like this:
1) client sends server of "job ABC": which files to load and how to
calculate them and where to save them. Please note the files are never
transfered over the network. They are always read/saved on the server
side.
2) server side does the job (IO, calculation) and when done, sends
something back to the client to inform the client "job ABC is done".
3) then the client can retrieve the results from server for display.
(The results are just some numbers so should be fast over the network).

For this application, which architecture / packages / classes should we
use? It would be very useful if someone can write a "pseudo" code so
that I can know which methods to use are best in terms of efficiency as
well as easy to code. And a set of keywords so that I can google them
for the details. Also, is the simple examples from sun's site:
http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
good for real applications such as the one I need? (I am guessing a lot
of "hello world" applcations are really not that good in real world)

As the above task, any pitfalls, shortcuts, known bugs or issues, or
anything else that should pay special attention?

Thank you a lot!

I'd start by looking at remote method invocation (RMI). This is a classic case
of remote execution. RMI handles the serialization of the request objects sent
to the server, performs some operation and returns the results.

I'd have thought that Sockets would be too low a level to begin with. You could
do it with Sockets, but RMI provides you with a higher level of abstraction.
This allows you to concentrate your effort on the client/server logic without
having to worry about the nitty gritty details of the network protocols.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top