下面列出了怎么用io.netty.channel.sctp.SctpServerChannel的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public SctpServerChannel parent() {
return (SctpServerChannel) super.parent();
}
@Override
public SctpServerChannel parent() {
return (SctpServerChannel) super.parent();
}
@Override
protected Class<? extends SctpServerChannel> serverClass() {
return OioSctpServerChannel.class;
}
@Override
protected Class<? extends SctpServerChannel> serverClass() {
return NioSctpServerChannel.class;
}
@Override
public SctpServerChannel parent() {
return (SctpServerChannel) super.parent();
}
@Override
public SctpServerChannel parent() {
return (SctpServerChannel) super.parent();
}
private void initSocket() throws Exception {
ServerBootstrap b = new ServerBootstrap();
b.group(this.management.getBossGroup(), this.management.getWorkerGroup());
if (this.ipChannelType == IpChannelType.SCTP) {
b.channel(NioSctpServerChannel.class);
b.option(ChannelOption.SO_BACKLOG, 100);
b.childHandler(new NettySctpServerChannelInitializer(this, this.management));
this.applySctpOptions(b);
} else {
b.channel(NioServerSocketChannel.class);
b.option(ChannelOption.SO_BACKLOG, 100);
b.childHandler(new NettyTcpServerChannelInitializer(this, this.management));
}
b.handler(new LoggingHandler(LogLevel.INFO));
InetSocketAddress localAddress = new InetSocketAddress(this.hostAddress, this.hostport);
// Bind the server to primary address.
ChannelFuture channelFuture = b.bind(localAddress).sync();
// Get the underlying sctp channel
if (this.ipChannelType == IpChannelType.SCTP) {
this.serverChannelSctp = (SctpServerChannel) channelFuture.channel();
// Bind the secondary address.
// Please note that, bindAddress in the client channel should be done before connecting if you have not
// enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param
if (this.extraHostAddresses != null) {
for (int count = 0; count < this.extraHostAddresses.length; count++) {
String localSecondaryAddress = this.extraHostAddresses[count];
InetAddress localSecondaryInetAddress = InetAddress.getByName(localSecondaryAddress);
channelFuture = this.serverChannelSctp.bindAddress(localSecondaryInetAddress).sync();
}
}
if (logger.isInfoEnabled()) {
logger.info(String.format("SctpServerChannel bound to=%s ", this.serverChannelSctp.allLocalAddresses()));
}
} else {
this.serverChannelTcp = (NioServerSocketChannel) channelFuture.channel();
if (logger.isInfoEnabled()) {
logger.info(String.format("ServerSocketChannel bound to=%s ", this.serverChannelTcp.localAddress()));
}
}
}