Extending java.net.Socket
I'm trying to extend the Socket class to add two new methods, getName and setName, so that I can associate names with each socket. Everything compiles fine, but I get a client-side runtime error while attempting to connect to the server.
The problem occurs when ServerSocket.accept() returns a Socket for the connecting client, which I then have to downcast to my extended Socket class (called User) in the line "User client = (User) ss.accept();", where "ss" is the ServerSocket. I'm assuming that the Socket object isn't being cast into a User properly, causing the client to remain disconnected and throw the "socket not connected" error when it tries to establish I/O streams.
Is there any way I can fix this?