/* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
void test(String[] args) { if (!Util.isSCTPSupported()) {
out.println("SCTP protocol is not supported");
out.println("Test cannot be run"); return;
}
doTest();
}
void doTest() {
SctpChannel channel = null;
try (SctpServerChannel ssc = SctpServerChannel.open()) { /* Create a server channel to connect to */
ssc.bind(null);
Set<SocketAddress> addrs = ssc.getAllLocalAddresses(); if (addrs.isEmpty())
debug("addrs should not be empty"); final SocketAddress peerAddress = (InetSocketAddress) addrs.iterator().next();
channel = SctpChannel.open();
/* TEST 0.5 Verify default values for new/unconnected channel */
check(channel.getRemoteAddresses().isEmpty(), "non empty set for unconnected channel");
check(channel.association() == null, "non-null association for unconnected channel");
check(!channel.isConnectionPending(), "should not have a connection pending");
/* TEST 1: non-blocking connect */
channel.configureBlocking(false); if (channel.connect(peerAddress) != true) {
debug("non-blocking connect did not immediately succeed");
check(channel.isConnectionPending(), "should return true for isConnectionPending"); try {
channel.connect(peerAddress);
fail("should have thrown ConnectionPendingException");
} catch (ConnectionPendingException cpe) {
pass();
} catch (IOException ioe) {
unexpected(ioe);
}
channel.configureBlocking(true);
check(channel.finishConnect(), "finishConnect should have returned true");
}
ssc.accept();
ssc.close();
/* TEST 1.5 Verify after connect */
check(!channel.getRemoteAddresses().isEmpty(), "empty set for connected channel");
check(channel.association() != null, "null association for connected channel");
check(!channel.isConnectionPending(), "pending connection for connected channel");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.