java.nio.channels.UnsupportedAddressTypeException#java.net.StandardSocketOptions源码实例Demo

下面列出了java.nio.channels.UnsupportedAddressTypeException#java.net.StandardSocketOptions 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tephra   文件: AioServerImpl.java
@Override
public void listen(int thread, int port, AioServerListener listener) {
    this.port = port;
    this.listener = listener;
    try {
        channelGroup = AsynchronousChannelGroup.withFixedThreadPool(thread, Executors.defaultThreadFactory());
        serverSocketChannel = AsynchronousServerSocketChannel.open(channelGroup);
        serverSocketChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
        serverSocketChannel.bind(new InetSocketAddress(port));
        serverSocketChannel.accept(null, this);

        if (logger.isInfoEnable())
            logger.info("启动AIO监听[{}]服务。", port);
    } catch (IOException e) {
        logger.warn(e, "启动AIO监听[{}]服务时发生异常!", port);
    }
}
 
源代码2 项目: hottub   文件: AsynchronousSocketChannelImpl.java
@Override
@SuppressWarnings("unchecked")
public final <T> T getOption(SocketOption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
    } finally {
        end();
    }
}
 
@Override
public final <T> AsynchronousSocketChannel setOption(SocketOption<T> name, T value)
    throws IOException
{
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (writeShutdown)
            throw new IOException("Connection has been shutdown for writing");
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            isReuseAddress = (Boolean)value;
        } else {
            Net.setSocketOption(fd, Net.UNSPEC, name, value);
        }
        return this;
    } finally {
        end();
    }
}
 
@Override
@SuppressWarnings("unchecked")
public final <T> T getOption(SocketOption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
    } finally {
        end();
    }
}
 
源代码5 项目: parity   文件: FIXAcceptor.java
Session accept() {
    try {
        SocketChannel fix = serverChannel.accept();
        if (fix == null)
            return null;

        try {
            fix.setOption(StandardSocketOptions.TCP_NODELAY, true);
            fix.configureBlocking(false);

            return new Session(orderEntry, fix, config, instruments);
        } catch (IOException e1) {
            fix.close();

            return null;
        }
    } catch (IOException e2) {
        return null;
    }
}
 
@Override
@SuppressWarnings("unchecked")
public final <T> T getOption(SocketOption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
    } finally {
        end();
    }
}
 
@Override
public final <T> AsynchronousSocketChannel setOption(SocketOption<T> name, T value)
    throws IOException
{
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (writeShutdown)
            throw new IOException("Connection has been shutdown for writing");
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            isReuseAddress = (Boolean)value;
        } else {
            Net.setSocketOption(fd, Net.UNSPEC, name, value);
        }
        return this;
    } finally {
        end();
    }
}
 
@Override
@SuppressWarnings("unchecked")
public final <T> T getOption(SocketOption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
    } finally {
        end();
    }
}
 
源代码9 项目: j2objc   文件: DatagramChannelTest.java
public void test_setOption() throws Exception {
    DatagramChannel dc = DatagramChannel.open();
    // There were problems in the past as the number used here was below the minimum for
    // some platforms (b/27821554). It was increased from 1024 to 4096.
    dc.setOption(StandardSocketOptions.SO_SNDBUF, 4096);

    // Assert that we can read back the option from the channel...
    assertEquals(4096, (int) dc.getOption(StandardSocketOptions.SO_SNDBUF));
    // ... and its socket adaptor.
    assertEquals(4096, dc.socket().getSendBufferSize());

    dc.close();
    try {
        dc.setOption(StandardSocketOptions.SO_SNDBUF, 4096);
        fail();
    } catch (ClosedChannelException expected) {
    }
}
 
源代码10 项目: Bytecoder   文件: NioSocketImpl.java
@SuppressWarnings("unchecked")
protected <T> T getOption(SocketOption<T> opt) throws IOException {
    if (!supportedOptions().contains(opt))
        throw new UnsupportedOperationException("'" + opt + "' not supported");
    synchronized (stateLock) {
        ensureOpen();
        if (opt == StandardSocketOptions.IP_TOS) {
            return (T) Net.getSocketOption(fd, family(), opt);
        } else if (opt == StandardSocketOptions.SO_REUSEADDR) {
            if (Net.useExclusiveBind()) {
                return (T) Boolean.valueOf(isReuseAddress);
            } else {
                return (T) Net.getSocketOption(fd, opt);
            }
        } else {
            // option does not need special handling
            return (T) Net.getSocketOption(fd, opt);
        }
    }
}
 
源代码11 项目: jdk8u-jdk   文件: AsynchronousSocketChannelImpl.java
@Override
public final <T> AsynchronousSocketChannel setOption(SocketOption<T> name, T value)
    throws IOException
{
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (writeShutdown)
            throw new IOException("Connection has been shutdown for writing");
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            isReuseAddress = (Boolean)value;
        } else {
            Net.setSocketOption(fd, Net.UNSPEC, name, value);
        }
        return this;
    } finally {
        end();
    }
}
 
源代码12 项目: hottub   文件: JdpBroadcaster.java
/**
 * Create a new broadcaster
 *
 * @param address - multicast group address
 * @param srcAddress - address of interface we should use to broadcast.
 * @param port - udp port to use
 * @param ttl - packet ttl
 * @throws IOException
 */
public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl)
        throws IOException, JdpException {
    this.addr = address;
    this.port = port;

    ProtocolFamily family = (address instanceof Inet6Address)
            ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;

    channel = DatagramChannel.open(family);
    channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl);

    // with srcAddress equal to null, this constructor do exactly the same as
    // if srcAddress is not passed
    if (srcAddress != null) {
        // User requests particular interface to bind to
        NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
        try {
            channel.bind(new InetSocketAddress(srcAddress, 0));
        } catch (UnsupportedAddressTypeException ex) {
            throw new JdpException("Unable to bind to source address");
        }
        channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
    }
}
 
@Override
public final <T> AsynchronousServerSocketChannel setOption(SocketOption<T> name,
                                                           T value)
    throws IOException
{
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            isReuseAddress = (Boolean)value;
        } else {
            Net.setSocketOption(fd, Net.UNSPEC, name, value);
        }
        return this;
    } finally {
        end();
    }
}
 
源代码14 项目: openjdk-8-source   文件: JdpBroadcaster.java
/**
 * Create a new broadcaster
 *
 * @param address - multicast group address
 * @param srcAddress - address of interface we should use to broadcast.
 * @param port - udp port to use
 * @param ttl - packet ttl
 * @throws IOException
 */
public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl)
        throws IOException, JdpException {
    this.addr = address;
    this.port = port;

    ProtocolFamily family = (address instanceof Inet6Address)
            ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;

    channel = DatagramChannel.open(family);
    channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl);

    // with srcAddress equal to null, this constructor do exactly the same as
    // if srcAddress is not passed
    if (srcAddress != null) {
        // User requests particular interface to bind to
        NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
        try {
            channel.bind(new InetSocketAddress(srcAddress, 0));
        } catch (UnsupportedAddressTypeException ex) {
            throw new JdpException("Unable to bind to source address");
        }
        channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
    }
}
 
源代码15 项目: Bytecoder   文件: NioSocketImpl.java
@Override
protected <T> void setOption(SocketOption<T> opt, T value) throws IOException {
    if (!supportedOptions().contains(opt))
        throw new UnsupportedOperationException("'" + opt + "' not supported");
    if (!opt.type().isInstance(value))
        throw new IllegalArgumentException("Invalid value '" + value + "'");
    synchronized (stateLock) {
        ensureOpen();
        if (opt == StandardSocketOptions.IP_TOS) {
            // maps to IP_TOS or IPV6_TCLASS
            Net.setSocketOption(fd, family(), opt, value);
        } else if (opt == StandardSocketOptions.SO_REUSEADDR) {
            boolean b = (boolean) value;
            if (Net.useExclusiveBind()) {
                isReuseAddress = b;
            } else {
                Net.setSocketOption(fd, opt, b);
            }
        } else {
            // option does not need special handling
            Net.setSocketOption(fd, opt, value);
        }
    }
}
 
源代码16 项目: Mycat2   文件: NIOAcceptor.java
public NIOAcceptor(String name, String bindIp,int port, 
		FrontendConnectionFactory factory, NIOReactorPool reactorPool)
		throws IOException {
	super.setName(name);
	this.port = port;
	this.selector = Selector.open();
	this.serverChannel = ServerSocketChannel.open();
	this.serverChannel.configureBlocking(false);
	/** 设置TCP属性 */
	serverChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
	serverChannel.setOption(StandardSocketOptions.SO_RCVBUF, 1024 * 16 * 2);
	// backlog=100
	serverChannel.bind(new InetSocketAddress(bindIp, port), 100);
	this.serverChannel.register(selector, SelectionKey.OP_ACCEPT);
	this.factory = factory;
	this.reactorPool = reactorPool;
}
 
源代码17 项目: openjdk-jdk8u   文件: JdpBroadcaster.java
/**
 * Create a new broadcaster
 *
 * @param address - multicast group address
 * @param srcAddress - address of interface we should use to broadcast.
 * @param port - udp port to use
 * @param ttl - packet ttl
 * @throws IOException
 */
public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl)
        throws IOException, JdpException {
    this.addr = address;
    this.port = port;

    ProtocolFamily family = (address instanceof Inet6Address)
            ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;

    channel = DatagramChannel.open(family);
    channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl);

    // with srcAddress equal to null, this constructor do exactly the same as
    // if srcAddress is not passed
    if (srcAddress != null) {
        // User requests particular interface to bind to
        NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
        try {
            channel.bind(new InetSocketAddress(srcAddress, 0));
        } catch (UnsupportedAddressTypeException ex) {
            throw new JdpException("Unable to bind to source address");
        }
        channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
    }
}
 
源代码18 项目: jdk8u-jdk   文件: JdpBroadcaster.java
/**
 * Create a new broadcaster
 *
 * @param address - multicast group address
 * @param srcAddress - address of interface we should use to broadcast.
 * @param port - udp port to use
 * @param ttl - packet ttl
 * @throws IOException
 */
public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl)
        throws IOException, JdpException {
    this.addr = address;
    this.port = port;

    ProtocolFamily family = (address instanceof Inet6Address)
            ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;

    channel = DatagramChannel.open(family);
    channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl);

    // with srcAddress equal to null, this constructor do exactly the same as
    // if srcAddress is not passed
    if (srcAddress != null) {
        // User requests particular interface to bind to
        NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
        try {
            channel.bind(new InetSocketAddress(srcAddress, 0));
        } catch (UnsupportedAddressTypeException ex) {
            throw new JdpException("Unable to bind to source address");
        }
        channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
    }
}
 
源代码19 项目: nifi   文件: ChannelListener.java
/**
 * Adds a server socket channel for listening to connections.
 *
 * @param nicIPAddress - if null binds to wildcard address
 * @param port - port to bind to
 * @param receiveBufferSize - size of OS receive buffer to request. If less
 * than 0 then will not be set and OS default will win.
 * @throws IOException if unable to add socket
 */
public void addServerSocket(final InetAddress nicIPAddress, final int port, final int receiveBufferSize)
        throws IOException {
    final ServerSocketChannel ssChannel = ServerSocketChannel.open();
    ssChannel.configureBlocking(false);
    if (receiveBufferSize > 0) {
        ssChannel.setOption(StandardSocketOptions.SO_RCVBUF, receiveBufferSize);
        final int actualReceiveBufSize = ssChannel.getOption(StandardSocketOptions.SO_RCVBUF);
        if (actualReceiveBufSize < receiveBufferSize) {
            LOGGER.warn(this + " attempted to set TCP Receive Buffer Size to "
                    + receiveBufferSize + " bytes but could only set to " + actualReceiveBufSize
                    + "bytes. You may want to consider changing the Operating System's "
                    + "maximum receive buffer");
        }
    }
    ssChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    ssChannel.bind(new InetSocketAddress(nicIPAddress, port));
    ssChannel.register(serverSocketSelector, SelectionKey.OP_ACCEPT);
}
 
@Override
@SuppressWarnings("unchecked")
public final <T> T getOption(SocketOption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketOptions.SO_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
    } finally {
        end();
    }
}
 
源代码21 项目: nifi   文件: DatagramChannelSender.java
@Override
public void open() throws IOException {
    if (channel == null) {
        channel = DatagramChannel.open();

        if (maxSendBufferSize > 0) {
            channel.setOption(StandardSocketOptions.SO_SNDBUF, maxSendBufferSize);
            final int actualSendBufSize = channel.getOption(StandardSocketOptions.SO_SNDBUF);
            if (actualSendBufSize < maxSendBufferSize) {
                logger.warn("Attempted to set Socket Send Buffer Size to " + maxSendBufferSize
                        + " bytes but could only set to " + actualSendBufSize + "bytes. You may want to "
                        + "consider changing the Operating System's maximum receive buffer");
            }
        }
    }

    if (!channel.isConnected()) {
        channel.connect(new InetSocketAddress(InetAddress.getByName(host), port));
    }
}
 
源代码22 项目: jdk8u-jdk   文件: JdpBroadcaster.java
/**
 * Create a new broadcaster
 *
 * @param address - multicast group address
 * @param srcAddress - address of interface we should use to broadcast.
 * @param port - udp port to use
 * @param ttl - packet ttl
 * @throws IOException
 */
public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl)
        throws IOException, JdpException {
    this.addr = address;
    this.port = port;

    ProtocolFamily family = (address instanceof Inet6Address)
            ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;

    channel = DatagramChannel.open(family);
    channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl);

    // with srcAddress equal to null, this constructor do exactly the same as
    // if srcAddress is not passed
    if (srcAddress != null) {
        // User requests particular interface to bind to
        NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
        try {
            channel.bind(new InetSocketAddress(srcAddress, 0));
        } catch (UnsupportedAddressTypeException ex) {
            throw new JdpException("Unable to bind to source address");
        }
        channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
    }
}
 
源代码23 项目: Bytecoder   文件: NioSocketImpl.java
/**
 * Closes the socket. If there are I/O operations in progress then the
 * socket is pre-closed and the threads are signalled. The socket will be
 * closed when the last I/O operation aborts.
 */
@Override
protected void close() throws IOException {
    synchronized (stateLock) {
        int state = this.state;
        if (state >= ST_CLOSING)
            return;
        if (state == ST_NEW) {
            // stillborn
            this.state = ST_CLOSED;
            return;
        }
        this.state = ST_CLOSING;

        // shutdown output when linger interval not set to 0
        try {
            var SO_LINGER = StandardSocketOptions.SO_LINGER;
            if ((int) Net.getSocketOption(fd, SO_LINGER) != 0) {
                Net.shutdown(fd, Net.SHUT_WR);
            }
        } catch (IOException ignore) { }

        // attempt to close the socket. If there are I/O operations in progress
        // then the socket is pre-closed and the thread(s) signalled. The
        // last thread will close the file descriptor.
        if (!tryClose()) {
            nd.preClose(fd);
            long reader = readerThread;
            if (reader != 0)
                NativeThread.signal(reader);
            long writer = writerThread;
            if (writer != 0)
                NativeThread.signal(writer);
        }
    }
}
 
private static Set<SocketOption<?>> defaultOptions() {
    HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.TCP_NODELAY);
    return Collections.unmodifiableSet(set);
}
 
源代码25 项目: openjdk-jdk8u   文件: ServerSocketAdaptor.java
public int getReceiveBufferSize() throws SocketException {
    try {
        return ssc.getOption(StandardSocketOptions.SO_RCVBUF).intValue();
    } catch (IOException x) {
        Net.translateToSocketException(x);
        return -1;          // Never happens
    }
}
 
源代码26 项目: Bytecoder   文件: NioSocketImpl.java
@Override
protected Set<SocketOption<?>> supportedOptions() {
    Set<SocketOption<?>> options = (server) ? serverSocketOptions : clientSocketOptions;
    if (options == null) {
        options = new HashSet<>();
        options.add(StandardSocketOptions.SO_RCVBUF);
        options.add(StandardSocketOptions.SO_REUSEADDR);
        if (server) {
            // IP_TOS added for server socket to maintain compatibility
            options.add(StandardSocketOptions.IP_TOS);
            options.addAll(ExtendedSocketOptions.serverSocketOptions());
        } else {
            options.add(StandardSocketOptions.IP_TOS);
            options.add(StandardSocketOptions.SO_KEEPALIVE);
            options.add(StandardSocketOptions.SO_SNDBUF);
            options.add(StandardSocketOptions.SO_LINGER);
            options.add(StandardSocketOptions.TCP_NODELAY);
            options.addAll(ExtendedSocketOptions.clientSocketOptions());
        }
        if (Net.isReusePortAvailable())
            options.add(StandardSocketOptions.SO_REUSEPORT);
        options = Collections.unmodifiableSet(options);
        if (server) {
            serverSocketOptions = options;
        } else {
            clientSocketOptions = options;
        }
    }
    return options;
}
 
源代码27 项目: netcrusher-java   文件: TcpBulkServer.java
public TcpBulkServer(InetSocketAddress address, long limit) throws IOException {
    this.serverSocketChannel = ServerSocketChannel.open();
    this.serverSocketChannel.configureBlocking(true);
    this.serverSocketChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    this.serverSocketChannel.bind(address);

    this.acceptor = new Acceptor(serverSocketChannel, limit);
}
 
源代码28 项目: dble   文件: NIOAcceptor.java
public NIOAcceptor(String name, String bindIp, int port, int backlog, FrontendConnectionFactory factory,
                   NIOReactorPool reactorPool) throws IOException {
    super.setName(name);
    this.port = port;
    this.selector = Selector.open();
    this.serverChannel = ServerSocketChannel.open();
    this.serverChannel.configureBlocking(false);
    //set TCP option
    serverChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
    serverChannel.setOption(StandardSocketOptions.SO_RCVBUF, 1024 * 16 * 2);
    serverChannel.bind(new InetSocketAddress(bindIp, port), backlog);
    this.serverChannel.register(selector, SelectionKey.OP_ACCEPT);
    this.factory = factory;
    this.reactorPool = reactorPool;
}
 
源代码29 项目: openjdk-jdk8u   文件: ServerSocketAdaptor.java
public boolean getReuseAddress() throws SocketException {
    try {
        return ssc.getOption(StandardSocketOptions.SO_REUSEADDR).booleanValue();
    } catch (IOException x) {
        Net.translateToSocketException(x);
        return false;       // Never happens
    }
}
 
源代码30 项目: dragonwell8_jdk   文件: ServerSocketAdaptor.java
public void setReceiveBufferSize(int size) throws SocketException {
    // size 0 valid for ServerSocketChannel, invalid for ServerSocket
    if (size <= 0)
        throw new IllegalArgumentException("size cannot be 0 or negative");
    try {
        ssc.setOption(StandardSocketOptions.SO_RCVBUF, size);
    } catch (IOException x) {
        Net.translateToSocketException(x);
    }
}