Java 1.4 NIO and SSL
843811Feb 2 2005 — edited Oct 27 2005This is a workarround to get NIO+SSL with java 1.4:
1. You can get a Socket from a SocketChannel with SocketChannel.getSocket() (Always).
(SocketChannel created with SocketChannel.open() or ServerSocketChannel.accept())
2. Next, you can upgrade the Socket to a SSLSocket with:
http://java.sun.com/j2se/1.4.2/docs/api/javax/net/ssl/SSLSocketFactory.html#cre ateSocket(java.net.Socket,%20java.lang.String,%20int,%20boolean)
3. Now, you can do select operations whith the SocketChannel if it is in non-blocking mode
and write/read with socket.getOutputStream() / socket.getInputStream() if it is in blocking mode.
4. You need to change the blocking mode each time you want to select or read/write.
(It implies register / deregister the SocketChannel with the selector each time)
Vicen�