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!
Paul Hamaker - 25 Feb 2006 10:18 GMT
Sockets are the fastest way to go. Example :
http://javalessons.com/cgi-bin/fun/java-tutorials-main.cgi?ses=ao789&sub=adv&code=sok
Especially the note about DataOut/InputStream and ObjectOIS.
---------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com
Jean-Paul - 25 Feb 2006 12:11 GMT
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.
frankgerlach@gmail.com - 25 Feb 2006 13:21 GMT
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.
jlp - 25 Feb 2006 17:53 GMT
frankgerlach@gmail.com 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 ;-)
jlp - 25 Feb 2006 18:06 GMT
Kevin a écrit :
> Sorry I am really new to "network" things. :-D
>
[quoted text clipped - 27 lines]
>
> 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 ...
Patrick May - 25 Feb 2006 19:38 GMT
> There is a task like:
> previously, the program does a lot of IO and calculation and shows
[quoted text clipped - 12 lines]
> (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
------------------------------------------------------------------------
S P Engineering, Inc. | The experts in large scale distributed OO
| systems design and implementation.
pjm@spe.com | (C++, Java, Common Lisp, Jini, CORBA, UML)
Kevin - 25 Feb 2006 23:59 GMT
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. :-)
Nigel Wade - 27 Feb 2006 16:47 GMT
> Sorry I am really new to "network" things. :-D
>
[quoted text clipped - 27 lines]
>
> 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.

Signature
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555