本文整理汇总了Java中com.sun.nio.sctp.SctpSocketOption.equals方法的典型用法代码示例。如果您正苦于以下问题:Java SctpSocketOption.equals方法的具体用法?Java SctpSocketOption.equals怎么用?Java SctpSocketOption.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.nio.sctp.SctpSocketOption
的用法示例。
在下文中一共展示了SctpSocketOption.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOption
import com.sun.nio.sctp.SctpSocketOption; //导入方法依赖的package包/类
@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;
}
示例2: getOption
import com.sun.nio.sctp.SctpSocketOption; //导入方法依赖的package包/类
@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);
}
}
示例3: getSocketOption
import com.sun.nio.sctp.SctpSocketOption; //导入方法依赖的package包/类
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");
}
}
示例4: setSocketOption
import com.sun.nio.sctp.SctpSocketOption; //导入方法依赖的package包/类
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");
}
}