Passing Objects from Client to Server (and back again)
Hello forum, I having trouble with passing objects from client to server and back again.
a) I have created a client server relationship where by the client creates an instance of an object (player.class), fills it with some data (setPlayersName(String);) then passes it to the server. The Player object needed to implements Serializable before being sent.
b) The server then adds some more data (Vector of game objects) that is then passed back to the client and displayed within a Swing JPanel. Both 憄layer?object as identical on both client and server.
Now a) works fine, I have transferred the object and I have made sure that the data is present with the player object. However, when I try and reverse the process and send the same (serializable) object back to the client I obtain this error.
java.io.NotSerializableException: java.net.Socket
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at SendObjectThread.run(SendObjectThread.java:33)
Without pasting lots of code, would anyone know why it抯 saying that the object is not serializable even though I have successfully passed it in part a) of my application?
Thanks very much for your time,
Harold Clements

