There is a plain socket server listening on port 12345;
ServerSocket s = new ServerSocket(12345);
What I want to know is that
It is not possible to serve both http and https on the same port. However, it should in theory be possible to upgrade an existing http connection to use TLS if both the client and server supports it, see RFC 2817. The SSLSocketFactory class has a createSocket() function which can be used to upgrade an existing socket to SSL/TLS.
Disclaimer: I have not attempted to do this, and implementing RFC 2817 is likely non-trivial.
Edit: Apparently I was wrong, like Bruno wrote it is possible to serve http and https on the same port using a technology called port unification, which uses the first few bytes received to detect the protocol. There is an example of this included with the Netty (JBoss) framework.