You need to use the SSLEngine
, as documented in Non-blocking I/O with SSLEngine. The libraries you mention use it or use libraries that use it.
(Note that this is notoriously difficult to use.)
You may find these links interesting:
For Datagrams, you should look into using DTLS instead of TLS. I'm not sure of its implementation status in Java, but you could dig through the archives of the java.openjdk.security.devel
mailing list.