|
Java example source code file (NioSctpServerChannel.java)
The NioSctpServerChannel.java Java example source code/* * Copyright 2011 The Netty Project * * The Netty Project licenses this file to you under the Apache License, * version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ package io.netty.channel.sctp.nio; import com.sun.nio.sctp.SctpChannel; import com.sun.nio.sctp.SctpServerChannel; import io.netty.channel.ChannelException; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelOutboundBuffer; import io.netty.channel.ChannelPromise; import io.netty.channel.nio.AbstractNioMessageChannel; import io.netty.channel.sctp.DefaultSctpServerChannelConfig; import io.netty.channel.sctp.SctpServerChannelConfig; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.SelectionKey; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; /** * {@link io.netty.channel.sctp.SctpServerChannel} implementation which use non-blocking mode to accept new * connections and create the {@link NioSctpChannel} for them. * * Be aware that not all operations systems support SCTP. Please refer to the documentation of your operation system, * to understand what you need to do to use it. Also this feature is only supported on Java 7+. */ public class NioSctpServerChannel extends AbstractNioMessageChannel implements io.netty.channel.sctp.SctpServerChannel { private static final ChannelMetadata METADATA = new ChannelMetadata(false, 16); private static SctpServerChannel newSocket() { try { return SctpServerChannel.open(); } catch (IOException e) { throw new ChannelException( "Failed to open a server socket.", e); } } private final SctpServerChannelConfig config; /** * Create a new instance */ public NioSctpServerChannel() { super(null, newSocket(), SelectionKey.OP_ACCEPT); config = new NioSctpServerChannelConfig(this, javaChannel()); } @Override public ChannelMetadata metadata() { return METADATA; } @Override public Set<InetSocketAddress> allLocalAddresses() { try { final Set<SocketAddress> allLocalAddresses = javaChannel().getAllLocalAddresses(); final Set<InetSocketAddress> addresses = new LinkedHashSet Other Java examples (source code examples)Here is a short list of links related to this Java NioSctpServerChannel.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.