Posted By:
John_Tesmer
Posted On:
Thursday, May 17, 2001 07:56 AM
Absolutely! In J2SE, you can use functionality provided by streams...
You can create a new socket like this:
Socket soc_ClientConnection = new Socket("www.ThisIsMyClient.com", 12345);
This socket can be used to create a stream; it must be defined as an input or output stream like so:
OutputStream os_SocketStream= soc_ClientConnection.getOutputStream();
The getOutputStream() method returns an output stream. The ObjectOutputStream has methods which allow for the writing of serializable objects to this output stream. NOTE that the object must implement Serializable! A vector does implement this interface if I'm not mistaken...
ObjectOuptutStream oos_WriteObjectStream = new ObjectOutputStream(os_SocketStream);
Now, you can use oos_WriteObjectStream's writeObject() method to write objects such as vectors to the output stream. Use readObject() on the other client to reassemble the stream into a meaningful object.
See the API for more information about these methods... I'm writing this in a hurry so I may have left something out!
Hope this helps!