Here you can find the source of write(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf)
public static void write(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf) throws IOException
//package com.java2s; /* $Id: SSLUtil.java 394 2009-03-21 20:28:26Z $ * * (C) Copyright 2008-2013 Alexander Veit * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at/*from w ww. j av a2 s .c o m*/ * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngineResult; public class Main { public static void write(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf) throws IOException { assert p_outNetBuf.limit() == p_outNetBuf.capacity(); while (p_outAppBuf.hasRemaining()) { final SSLEngineResult l_res; // encrypt data l_res = p_sslEngine.wrap(p_outAppBuf, p_outNetBuf); switch (l_res.getStatus()) { case OK: case BUFFER_OVERFLOW: p_outNetBuf.flip(); // send the encrypted data to the peer while (p_outNetBuf.hasRemaining()) // coward loop { p_channel.write(p_outNetBuf); if (p_outNetBuf.hasRemaining()) Thread.yield(); // should not occur in blocking mode } p_outNetBuf.clear(); break; case BUFFER_UNDERFLOW: throw new AssertionError("SSL write status BUFFER_UNDERFLOW."); case CLOSED: throw new AssertionError("SSL write status CLOSED."); default: throw new AssertionError("SSL write: unexpected status " + l_res.getStatus() + "."); } } } }