I know that multiple questions have been asked about this, but none of them suit my needs. So sorry about that.
Anyways, my class AdvancedSocket extends java.net.Socket
. In my class AdvancedServerServer extends java.net.ServerSocket
. So, in AdvancedServerSocket, I override the accept()
method to return an AdvancedSocket
. Here is that method:
@Override
public AdvancedSocket accept() throws IOException {
return (AdvancedSocket) super.accept();
}
But this throws a java.lang.ClassCastException
.
in fact your accept method still returns usual socket (because you return super.accept()), how do you think it can be casted? You need convert it manually (build advanced socket on top of usual socket)