com.sun.nio.sctp.SctpSocketOption Java Examples
The following examples show how to use
com.sun.nio.sctp.SctpSocketOption.
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: SctpMultiChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public <T> SctpMultiChannel setOption(SctpSocketOption<T> name, T value, Association association) throws IOException { if (name == null) throw new NullPointerException(); if (!(supportedOptions().contains(name))) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (association != null && (name.equals(SCTP_PRIMARY_ADDR) || name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) { checkAssociation(association); } if (!isOpen()) throw new ClosedChannelException(); int assocId = association == null ? 0 : association.associationID(); SctpNet.setSocketOption(fdVal, name, value, assocId); } return this; }
Example #2
Source File: SctpMultiChannelImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public <T> T getOption(SctpSocketOption<T> name, Association association) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (association != null && (name.equals(SCTP_PRIMARY_ADDR) || name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) { checkAssociation(association); } if (!isOpen()) throw new ClosedChannelException(); int assocId = association == null ? 0 : association.associationID(); return (T)SctpNet.getSocketOption(fdVal, name, assocId); } }
Example #3
Source File: SctpNet.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static Object getIntOption(int fd, SctpSocketOption<?> name) throws IOException { Class<?> type = name.type(); if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); if (!(name instanceof SctpStdSocketOption)) throw new AssertionError("Should not reach here"); int value = getIntOption0(fd, ((SctpStdSocketOption)name).constValue()); if (type == Integer.class) { return Integer.valueOf(value); } else { return (value == 0) ? Boolean.FALSE : Boolean.TRUE; } }
Example #4
Source File: SctpServerChannelImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/); return this; } }
Example #5
Source File: SctpNet.java From hottub with GNU General Public License v2.0 | 6 votes |
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId) throws IOException { if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) { throw new IllegalArgumentException( "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved"); } else if (name.equals(SCTP_INIT_MAXSTREAMS)) { /* container for holding maxIn/Out streams */ int[] values = new int[2]; SctpNet.getInitMsgOption0(fd, values); return InitMaxStreams.create(values[0], values[1]); } else if (name.equals(SCTP_PRIMARY_ADDR)) { return getPrimAddrOption0(fd, assocId); } else if (name.equals(SCTP_DISABLE_FRAGMENTS) || name.equals(SCTP_EXPLICIT_COMPLETE) || name.equals(SCTP_FRAGMENT_INTERLEAVE) || name.equals(SCTP_NODELAY) || name.equals(SO_SNDBUF) || name.equals(SO_RCVBUF) || name.equals(SO_LINGER)) { return getIntOption(fd, name); } else { throw new AssertionError("Unknown socket option"); } }
Example #6
Source File: SctpChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public <T> SctpChannel setOption(SctpSocketOption<T> name, T value) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/); } return this; }
Example #7
Source File: SctpNet.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId) throws IOException { if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) { throw new IllegalArgumentException( "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved"); } else if (name.equals(SCTP_INIT_MAXSTREAMS)) { /* container for holding maxIn/Out streams */ int[] values = new int[2]; SctpNet.getInitMsgOption0(fd, values); return InitMaxStreams.create(values[0], values[1]); } else if (name.equals(SCTP_PRIMARY_ADDR)) { return getPrimAddrOption0(fd, assocId); } else if (name.equals(SCTP_DISABLE_FRAGMENTS) || name.equals(SCTP_EXPLICIT_COMPLETE) || name.equals(SCTP_FRAGMENT_INTERLEAVE) || name.equals(SCTP_NODELAY) || name.equals(SO_SNDBUF) || name.equals(SO_RCVBUF) || name.equals(SO_LINGER)) { return getIntOption(fd, name); } else { throw new AssertionError("Unknown socket option"); } }
Example #8
Source File: SctpMultiChannelImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public <T> T getOption(SctpSocketOption<T> name, Association association) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (association != null && (name.equals(SCTP_PRIMARY_ADDR) || name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) { checkAssociation(association); } if (!isOpen()) throw new ClosedChannelException(); int assocId = association == null ? 0 : association.associationID(); return (T)SctpNet.getSocketOption(fdVal, name, assocId); } }
Example #9
Source File: SctpNet.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
static Object getIntOption(int fd, SctpSocketOption<?> name) throws IOException { Class<?> type = name.type(); if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); if (!(name instanceof SctpStdSocketOption)) throw new AssertionError("Should not reach here"); int value = getIntOption0(fd, ((SctpStdSocketOption)name).constValue()); if (type == Integer.class) { return Integer.valueOf(value); } else { return (value == 0) ? Boolean.FALSE : Boolean.TRUE; } }
Example #10
Source File: SctpNet.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
static Object getIntOption(int fd, SctpSocketOption<?> name) throws IOException { Class<?> type = name.type(); if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); if (!(name instanceof SctpStdSocketOption)) throw new AssertionError("Should not reach here"); int value = getIntOption0(fd, ((SctpStdSocketOption)name).constValue()); if (type == Integer.class) { return Integer.valueOf(value); } else { return (value == 0) ? Boolean.FALSE : Boolean.TRUE; } }
Example #11
Source File: SctpNet.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static Object getIntOption(int fd, SctpSocketOption<?> name) throws IOException { Class<?> type = name.type(); if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); if (!(name instanceof SctpStdSocketOption)) throw new AssertionError("Should not reach here"); int value = getIntOption0(fd, ((SctpStdSocketOption)name).constValue()); if (type == Integer.class) { return Integer.valueOf(value); } else { return (value == 0) ? Boolean.FALSE : Boolean.TRUE; } }
Example #12
Source File: SocketOptionTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
<T> void optionalSupport(SctpChannel sc, SctpSocketOption<T> name, T value) { try { sc.setOption(name, value); checkOption(sc, name, value); } catch (IOException e) { /* Informational only, not all options have native support */ out.println(name + " not supported. " + e); } }
Example #13
Source File: SctpChannelImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T> T getOption(SctpSocketOption<T> name) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/); } }
Example #14
Source File: SctpServerChannelImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T> T getOption(SctpSocketOption<T> name) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/); } }
Example #15
Source File: SocketOptionTests.java From hottub with GNU General Public License v2.0 | 5 votes |
<T> void optionalSupport(SctpChannel sc, SctpSocketOption<T> name, T value) { try { sc.setOption(name, value); checkOption(sc, name, value); } catch (IOException e) { /* Informational only, not all options have native support */ out.println(name + " not supported. " + e); } }
Example #16
Source File: SctpChannelImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T> T getOption(SctpSocketOption<T> name) throws IOException { if (name == null) throw new NullPointerException(); if (!supportedOptions().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/); } }
Example #17
Source File: SctpChannelImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static Set<SctpSocketOption<?>> defaultOptions() { HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10); set.add(SCTP_DISABLE_FRAGMENTS); set.add(SCTP_EXPLICIT_COMPLETE); set.add(SCTP_FRAGMENT_INTERLEAVE); set.add(SCTP_INIT_MAXSTREAMS); set.add(SCTP_NODELAY); set.add(SCTP_PRIMARY_ADDR); set.add(SCTP_SET_PEER_PRIMARY_ADDR); set.add(SO_SNDBUF); set.add(SO_RCVBUF); set.add(SO_LINGER); return Collections.unmodifiableSet(set); }
Example #18
Source File: SctpMultiChannelImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static Set<SctpSocketOption<?>> defaultOptions() { HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10); set.add(SCTP_DISABLE_FRAGMENTS); set.add(SCTP_EXPLICIT_COMPLETE); set.add(SCTP_FRAGMENT_INTERLEAVE); set.add(SCTP_INIT_MAXSTREAMS); set.add(SCTP_NODELAY); set.add(SCTP_PRIMARY_ADDR); set.add(SCTP_SET_PEER_PRIMARY_ADDR); set.add(SO_SNDBUF); set.add(SO_RCVBUF); set.add(SO_LINGER); return Collections.unmodifiableSet(set); }
Example #19
Source File: SctpChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public <T> SctpChannel setOption(SctpSocketOption<T> name, T value) throws IOException { throw new UnsupportedOperationException(message); }
Example #20
Source File: SocketOptionTests.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
<T> void checkOption(SctpMultiChannel smc, SctpSocketOption<T> name, T expectedValue) throws IOException { T value = smc.getOption(name, null); check(value.equals(expectedValue), name + ": value (" + value + ") not as expected (" + expectedValue + ")"); }
Example #21
Source File: SctpServerChannelImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Set<SctpSocketOption<?>> supportedOptions() { throw new UnsupportedOperationException(message); }
Example #22
Source File: SctpServerChannelImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public Set<SctpSocketOption<?>> supportedOptions() { throw new UnsupportedOperationException(message); }
Example #23
Source File: SctpNet.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
static <T> void setSocketOption(int fd, SctpSocketOption<T> name, T value, int assocId) throws IOException { if (value == null) throw new IllegalArgumentException("Invalid option value"); if (name.equals(SCTP_INIT_MAXSTREAMS)) { InitMaxStreams maxStreamValue = (InitMaxStreams)value; SctpNet.setInitMsgOption0(fd, maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams()); } else if (name.equals(SCTP_PRIMARY_ADDR) || name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) { SocketAddress addr = (SocketAddress) value; if (addr == null) throw new IllegalArgumentException("Invalid option value"); Net.checkAddress(addr); InetSocketAddress netAddr = (InetSocketAddress)addr; if (name.equals(SCTP_PRIMARY_ADDR)) { setPrimAddrOption0(fd, assocId, netAddr.getAddress(), netAddr.getPort()); } else { setPeerPrimAddrOption0(fd, assocId, netAddr.getAddress(), netAddr.getPort(), IPv4MappedAddresses()); } } else if (name.equals(SCTP_DISABLE_FRAGMENTS) || name.equals(SCTP_EXPLICIT_COMPLETE) || name.equals(SCTP_FRAGMENT_INTERLEAVE) || name.equals(SCTP_NODELAY) || name.equals(SO_SNDBUF) || name.equals(SO_RCVBUF) || name.equals(SO_LINGER)) { setIntOption(fd, name, value); } else { throw new AssertionError("Unknown socket option"); } }
Example #24
Source File: SctpMultiChannelImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public <T> SctpMultiChannel setOption(SctpSocketOption<T> name, T value, Association association) throws IOException { throw new UnsupportedOperationException(message); }
Example #25
Source File: SocketOptionTests.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
<T> void checkOption(SctpMultiChannel smc, SctpSocketOption<T> name, T expectedValue) throws IOException { T value = smc.getOption(name, null); check(value.equals(expectedValue), name + ": value (" + value + ") not as expected (" + expectedValue + ")"); }
Example #26
Source File: SctpServerChannelImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Override public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value) throws IOException { throw new UnsupportedOperationException(message); }
Example #27
Source File: SctpServerChannelImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public final Set<SctpSocketOption<?>> supportedOptions() { return DefaultOptionsHolder.defaultOptions; }
Example #28
Source File: SctpChannelImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public Set<SctpSocketOption<?>> supportedOptions() { throw new UnsupportedOperationException(message); }
Example #29
Source File: SctpServerChannelImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Override public final Set<SctpSocketOption<?>> supportedOptions() { return DefaultOptionsHolder.defaultOptions; }
Example #30
Source File: SctpChannelImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public <T> SctpChannel setOption(SctpSocketOption<T> name, T value) throws IOException { throw new UnsupportedOperationException(message); }