com.sun.nio.sctp.SctpServerChannel Java Examples

The following examples show how to use com.sun.nio.sctp.SctpServerChannel. 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: SctpServerChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 #2
Source File: Bind.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #3
Source File: SctpServerChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 #4
Source File: Bind.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #5
Source File: Bind.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #6
Source File: SctpServerChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 #7
Source File: Bind.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #8
Source File: Bind.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #9
Source File: Bind.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #10
Source File: Bind.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #11
Source File: Bind.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #12
Source File: NonBlockingAccept.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #13
Source File: SctpServerChannelImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #14
Source File: Send.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #15
Source File: SctpServerChannelImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #16
Source File: Receive.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #17
Source File: CommUp.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #18
Source File: SctpServerChannelImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #19
Source File: Shutdown.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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();

}
 
Example #20
Source File: SctpServerChannelImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #21
Source File: SctpServerChannelImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #22
Source File: NonBlockingAccept.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #23
Source File: SctpServerChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #24
Source File: Receive.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #25
Source File: NonBlockingAccept.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #26
Source File: ReceiveIntoDirect.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #27
Source File: SctpServerChannelImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #28
Source File: NonBlockingAccept.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #29
Source File: Shutdown.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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();

}
 
Example #30
Source File: CommUp.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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();
}