Java Code Examples for com.sun.nio.sctp.SctpChannel#close()
The following examples show how to use
com.sun.nio.sctp.SctpChannel#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NonBlockingAccept.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); } }
Example 2
Source File: NonBlockingAccept.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } }
Example 3
Source File: NioSctpChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
/** * Create a new instance * * @param parent the {@link Channel} which is the parent of this {@link NioSctpChannel} * or {@code null}. * @param sctpChannel the underlying {@link SctpChannel} */ public NioSctpChannel(Channel parent, SctpChannel sctpChannel) { super(parent, sctpChannel, SelectionKey.OP_READ); try { sctpChannel.configureBlocking(false); config = new NioSctpChannelConfig(this, sctpChannel); notificationHandler = new SctpNotificationHandler(this); } catch (IOException e) { try { sctpChannel.close(); } catch (IOException e2) { if (logger.isWarnEnabled()) { logger.warn( "Failed to close a partially initialized sctp channel.", e2); } } throw new ChannelException("Failed to enter non-blocking mode.", e); } }
Example 4
Source File: NonBlockingAccept.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example 5
Source File: NonBlockingAccept.java From hottub with GNU General Public License v2.0 | 6 votes |
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); } }
Example 6
Source File: OioSctpServerChannel.java From netty4.0.27Learn with Apache License 2.0 | 5 votes |
@Override protected int doReadMessages(List<Object> buf) throws Exception { if (!isActive()) { return -1; } SctpChannel s = null; int acceptedChannels = 0; try { final int selectedKeys = selector.select(SO_TIMEOUT); if (selectedKeys > 0) { final Iterator<SelectionKey> selectionKeys = selector.selectedKeys().iterator(); for (;;) { SelectionKey key = selectionKeys.next(); selectionKeys.remove(); if (key.isAcceptable()) { s = sch.accept(); if (s != null) { buf.add(new OioSctpChannel(this, s)); acceptedChannels ++; } } if (!selectionKeys.hasNext()) { return acceptedChannels; } } } } catch (Throwable t) { logger.warn("Failed to create a new channel from an accepted sctp channel.", t); if (s != null) { try { s.close(); } catch (Throwable t2) { logger.warn("Failed to close a sctp channel.", t2); } } } return acceptedChannels; }
Example 7
Source File: Util.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 8
Source File: Util.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 9
Source File: Accept.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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);} } }
Example 10
Source File: Util.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 11
Source File: Util.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 12
Source File: Accept.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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);} } }
Example 13
Source File: Util.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 14
Source File: Util.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 15
Source File: Util.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 16
Source File: MaxSequenceNumberTest.java From sctp with GNU Affero General Public License v3.0 | 5 votes |
/** * @return true if sctp is supported by this OS and false in not */ public static boolean checkSctpEnabled() { try { SctpChannel socketChannel = SctpChannel.open(); socketChannel.close(); return true; } catch (Exception e) { return false; } }
Example 17
Source File: Accept.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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);} } }
Example 18
Source File: Util.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static boolean isSCTPSupported() { try { SctpChannel c = SctpChannel.open(); c.close(); return true; } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedOperationException e) { out.println(e); } return false; }
Example 19
Source File: Accept.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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);} } }
Example 20
Source File: Receive.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public void run() { try { SctpChannel sc = ssc.accept(); /* send a small message */ MessageInfo info = MessageInfo.createOutgoing(null, 0) .payloadProtocolID(PPID); ByteBuffer buf = ByteBuffer.allocateDirect(Util.SMALL_BUFFER); buf.put(Util.SMALL_MESSAGE.getBytes("ISO-8859-1")); buf.flip(); debug("sending small message: " + buf); sc.send(buf, info); /* send a large message */ buf = ByteBuffer.allocateDirect(Util.LARGE_BUFFER); buf.put(Util.LARGE_MESSAGE.getBytes("ISO-8859-1")); buf.flip(); debug("sending large message: " + buf); sc.send(buf, info); sc.shutdown(); debug("shutdown"); ReceiveNotificationHandler handler = new ReceiveNotificationHandler(sc); sc.receive(buf, null, handler); sc.close(); /* accept another socket for the TEST 6 */ sc = ssc.accept(); ssc.close(); clientFinishedLatch.await(10L, TimeUnit.SECONDS); serverFinishedLatch.countDown(); sc.close(); } catch (IOException ioe) { unexpected(ioe); } catch (InterruptedException ie) { unexpected(ie); } }