Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java 1.4 NIO and SSL

843811Feb 2 2005 — edited Oct 27 2005
This 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�
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2005
Added on Feb 2 2005
7 comments
181 views