Java Sockets, Bytes / Objects
Hello All,
I'm new here to the Java programming forums, looks like a friendly place to get some advice.
Please excuse any naivety on my part, I'm rather new to socket programming in Java, and I'm actually just getting back into Java itself.
Basically I have a server / client setup and I need to transfer objects between the two.
I can currently transfer bytes via a buffer buffer, but I need custom objects.
What is the best method of transferring objects?
1. Converting the object to a byte array?
2. Using the object stream?
3.. or some other method.
Any advice would be great!
Re: Java Sockets, Bytes / Objects
Write the object to an ObjectOutputStream. Make sure the classes you wish to write implement Serializable, and any info you don't need to be written marked as transient.