As long as the object properly implements serialisable then you can send it through an ObjectOutputStream wrapped around the OutputStream retreived through socket.getOutputStream, and read through an ObjectInputStream wrapped around the receiving ends socket.getInputStream.
And, of course, RMI and CORBA are other possibilites as long as you define your stubs correctly. Sun provides an RMI tutorial here http://java.sun.com/docs/books/tutorial/rmi/index.html
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
RMI in fact makes working with remote objects a lot easier than doing the entire stuff of serialisation, transmission, and receiving yourself.
The actual overhead on the client is quite limited, little more than it would be if you were to establish a socket connection to the server (and the server becomes a lot easier to write).
The only disadvantage (which you'd also have if you're serialising objects yourself) is that it won't be portable to other platforms without serious effort.
Only platform agnostic systems like SOAP and Corba provide for that out of the box.
A complete mulithreaded server that will provide a single RMI service (Remote object) can be coded in about 10KB of Java code (not counting the Remote object itself, which is just a Java bean with some special rules) and about half of that's comments and logging code.
Those are real figures, figures from an RMI application I created for my certification (currently on hold still awaiting funds for the final exam).
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Depends on what you want.
If communication with non-Java systems is required, you will need to pass your data in a way that those platforms can understand.
The easiest way to do that is to use some protocol based on flat text with no binary data whatsoever.
Corba is hardly ever used anymore, been completely superceded by SOAP.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337