Search in sources :

Example 16 with SctpChannel

use of com.sun.nio.sctp.SctpChannel in project jdk8u_jdk by JetBrains.

the class NonBlockingAccept method doClient.

void doClient(SocketAddress peerAddress) {
    Set<SctpChannel> channels = new HashSet<SctpChannel>(NUM_TEST_CONNECTIONS);
    try {
        for (int i = 0; i < NUM_TEST_CONNECTIONS; ) {
            debug("connecting " + ++i);
            channels.add(SctpChannel.open(peerAddress, 0, 0));
            sleep(100);
        }
        /* don't close the channels until they have been accepted */
        acceptLatch.await();
        for (SctpChannel sc : channels) sc.close();
    } catch (IOException ioe) {
        unexpected(ioe);
    } catch (InterruptedException ie) {
        unexpected(ie);
    }
}
Also used : SctpChannel(com.sun.nio.sctp.SctpChannel) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 17 with SctpChannel

use of com.sun.nio.sctp.SctpChannel in project jdk8u_jdk by JetBrains.

the class Accept method doClient.

void doClient(SocketAddress peerAddress) {
    SctpChannel channel = null;
    try {
        channel = SctpChannel.open(peerAddress, 0, 0);
        acceptLatch.await();
        /* for test 4 */
        closeByIntLatch.await();
        sleep(500);
        server.thread().interrupt();
        /* for test 5 */
        asyncCloseLatch.await();
        sleep(500);
        server.channel().close();
        /* wait for the server thread to finish */
        join(server.thread(), 10000);
    } catch (IOException ioe) {
        unexpected(ioe);
    } catch (InterruptedException ie) {
        unexpected(ie);
    } finally {
        try {
            if (channel != null)
                channel.close();
        } catch (IOException e) {
            unexpected(e);
        }
    }
}
Also used : SctpChannel(com.sun.nio.sctp.SctpChannel) IOException(java.io.IOException)

Aggregations

SctpChannel (com.sun.nio.sctp.SctpChannel)17 IOException (java.io.IOException)8 ByteBuffer (java.nio.ByteBuffer)8 MessageInfo (com.sun.nio.sctp.MessageInfo)7 InetSocketAddress (java.net.InetSocketAddress)4 ClosedChannelException (java.nio.channels.ClosedChannelException)4 SctpServerChannel (com.sun.nio.sctp.SctpServerChannel)3 SocketAddress (java.net.SocketAddress)3 Association (com.sun.nio.sctp.Association)2 IllegalUnbindException (com.sun.nio.sctp.IllegalUnbindException)2 SctpMultiChannel (com.sun.nio.sctp.SctpMultiChannel)2 AlreadyBoundException (java.nio.channels.AlreadyBoundException)2 AlreadyConnectedException (java.nio.channels.AlreadyConnectedException)2 NotYetConnectedException (java.nio.channels.NotYetConnectedException)2 SelectionKey (java.nio.channels.SelectionKey)2 UnsupportedAddressTypeException (java.nio.channels.UnsupportedAddressTypeException)2 ByteBuf (io.netty.buffer.ByteBuf)1 RecvByteBufAllocator (io.netty.channel.RecvByteBufAllocator)1 SctpMessage (io.netty.channel.sctp.SctpMessage)1 FileDescriptor (java.io.FileDescriptor)1