Re: communication between 2 socket
I have to develop the following project:
( 1 Client with 1 server )
ServerPCL sends commands to ClientPLC that answers back.
( N Clients with 1 Server )
ClientPC sends commands to ServerPC that before sending back the answers,
communicate with the ServerPLC.
ClientPC sends command "AAA" -->
At this point the ClientPLC sends
Is that clear? :-)
Could you give me some links or hits to solve this puzzle?
You should be able to program that scenario with RMI.
Your ClientPC is a RMI client. Server PC is both a client and a server (to
ClientPC it's a server, but it is a client of ServerPLC), ServerPLC is also
both a client and a server. Finally, ClientPLC is just an RMI server.
RMI also supports multi-threaded servers, so your requirement for N clients with
1 server can be met. In this situation you just need to be sure that each
service method in the server is thread safe.
However, you probably won't be able to make the communication from ServerPC to
ServerPLC or ServerPLC to ClientPLC handle multiple ClientPCs simultaneously.
That would require a much higher level of sophistication than basic RMI
provides. For a server to handle multiple requests from the *same* client
simultaneously needs one communication channel per request, and basic RMI
doesn't do that.
Have a look at the Java Tutorial on RMI at
http://java.sun.com/docs/books/tutorial/rmi/index.html and see if you can make
sense of it...
Maybe there is a better way to solve it than what I have done ;-)
Given the constraints above, probably not. However, there may be a better way of
providing the functionality you require, but you didn't tell us what your basic
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : email@example.com
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555