I receive an error:
IOException on socket listen: java.io.NotSerializableException: java.net.Socket
i try to send an object via socket with this code :
ObjectOutputStream outObjects = new ObjectOutputStream(socket.getOutputStream());
outObjects.writeObject(currentPlayer);
output.flush();
second line gives error.... but i have serialized ( implements Serializable) the class Player (the class of the currentPlayer object) but one of the member of Player class is a Socket object..... i try to redefine and serializeble the socket object but no way to solve the problem.... where am i wrong ?
You can not serialize Socket object, therefore you should make socket field transient. If you need some of socket properties, you can put extra fields to Player to represent these fields.