本文整理汇总了Java中com.sun.nio.sctp.SctpServerChannel类的典型用法代码示例。如果您正苦于以下问题:Java SctpServerChannel类的具体用法?Java SctpServerChannel怎么用?Java SctpServerChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SctpServerChannel类属于com.sun.nio.sctp包,在下文中一共展示了SctpServerChannel类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
@Override
public void start() throws IOException {
this.sctpServerChannel = SctpServerChannel.open();
sctpServerChannel.bind( new InetSocketAddress(this.getIpAddress(),this.getPort()) );
sctpServerChannel.configureBlocking( false );
this.selector = Selector.open();
this.key = sctpServerChannel.register( selector, SelectionKey.OP_ACCEPT );
// Start a daemon thread to handle reception
this.isRunning = true;
Thread thread = new Thread(this);
thread.setDaemon(true);
thread.setName("SCTPMessageProcessorThread");
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
}
示例2: setOption
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
@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;
}
}
示例3: connectChannel
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
SctpChannel connectChannel(SctpChannel channel)
throws IOException {
debug("connecting channel...");
try {
SctpServerChannel ssc = SctpServerChannel.open();
ssc.bind(null);
Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
Iterator<SocketAddress> iterator = addrs.iterator();
SocketAddress addr = iterator.next();
debug("using " + addr + "...");
channel.connect(addr);
SctpChannel peerChannel = ssc.accept();
ssc.close();
debug("connected");
return peerChannel;
} catch (IOException ioe) {
debug("Cannot connect channel");
unexpected(ioe);
throw ioe;
}
}
示例4: bind
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
@Override
public SctpServerChannel bind(SocketAddress local, int backlog)
throws IOException {
synchronized (lock) {
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
if (isBound())
SctpNet.throwAlreadyBoundException();
InetSocketAddress isa = (local == null) ?
new InetSocketAddress(0) : Net.checkAddress(local);
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkListen(isa.getPort());
Net.bind(fd, isa.getAddress(), isa.getPort());
InetSocketAddress boundIsa = Net.localAddress(fd);
port = boundIsa.getPort();
localAddresses.add(isa);
if (isa.getAddress().isAnyLocalAddress())
wildcard = true;
SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
}
}
return this;
}
示例5: Server
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
public Server() throws IOException {
ssc = SctpServerChannel.open().bind(null);
java.util.Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
if (addrs.isEmpty())
debug("addrs should not be empty");
serverAddr = (InetSocketAddress) addrs.iterator().next();
}
示例6: CommUpServer
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
public CommUpServer() throws IOException {
ssc = SctpServerChannel.open().bind(null);
java.util.Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
if (addrs.isEmpty())
debug("addrs should not be empty");
serverAddr = (InetSocketAddress) addrs.iterator().next();
}
示例7: ShutdownServer
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
public ShutdownServer() throws IOException {
ssc = SctpServerChannel.open().bind(null);
//serverAddr = (InetSocketAddress)(ssc.getAllLocalAddresses().iterator().next());
java.util.Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
if (addrs.isEmpty())
debug("addrs should not be empty");
serverAddr = (InetSocketAddress) addrs.iterator().next();
}
示例8: NonblockingServer
import com.sun.nio.sctp.SctpServerChannel; //导入依赖的package包/类
public NonblockingServer() throws IOException {
ssc = SctpServerChannel.open().bind(null);
java.util.Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
if (addrs.isEmpty())
debug("addrs should not be empty");
serverAddr = (InetSocketAddress) addrs.iterator().next();
}