java.net.ServerSocket.getReuseAddress()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中java.net.ServerSocket.getReuseAddress()方法的一些代码示例,展示了ServerSocket.getReuseAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ServerSocket.getReuseAddress()方法的具体详情如下:
包路径:java.net.ServerSocket
类名称:ServerSocket
方法名:getReuseAddress

ServerSocket.getReuseAddress介绍

[英]Gets the value of the socket option SocketOptions.SO_REUSEADDR.
[中]获取套接字选项SocketOptions的值。所以!。

代码示例

代码示例来源:origin: netty/netty

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: io.netty/netty

public boolean isReuseAddress() {
  try {
    return socket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: wildfly/wildfly

public <T> T getOption(final Option<T> option) throws UnsupportedOptionException, IOException {
  if (option == Options.REUSE_ADDRESSES) {
    return option.cast(Boolean.valueOf(socket.getReuseAddress()));
  } else if (option == Options.RECEIVE_BUFFER) {
    return option.cast(Integer.valueOf(socket.getReceiveBufferSize()));
  } else if (option == Options.SEND_BUFFER) {
    final int value = sendBuffer;
    return value == -1 ? null : option.cast(Integer.valueOf(value));
  } else if (option == Options.KEEP_ALIVE) {
    return option.cast(Boolean.valueOf(keepAlive != 0));
  } else if (option == Options.TCP_OOB_INLINE) {
    return option.cast(Boolean.valueOf(oobInline != 0));
  } else if (option == Options.TCP_NODELAY) {
    return option.cast(Boolean.valueOf(tcpNoDelay != 0));
  } else if (option == Options.READ_TIMEOUT) {
    return option.cast(Integer.valueOf(readTimeout));
  } else if (option == Options.WRITE_TIMEOUT) {
    return option.cast(Integer.valueOf(writeTimeout));
  } else if (option == Options.CONNECTION_HIGH_WATER) {
    return option.cast(Integer.valueOf(getHighWater(connectionStatus)));
  } else if (option == Options.CONNECTION_LOW_WATER) {
    return option.cast(Integer.valueOf(getLowWater(connectionStatus)));
  } else {
    return null;
  }
}

代码示例来源:origin: wildfly/wildfly

public <T> T getOption(final Option<T> option) throws UnsupportedOptionException, IOException {
  if (option == Options.REUSE_ADDRESSES) {
    return option.cast(Boolean.valueOf(socket.getReuseAddress()));
  } else if (option == Options.RECEIVE_BUFFER) {
    return option.cast(Integer.valueOf(socket.getReceiveBufferSize()));
  } else if (option == Options.SEND_BUFFER) {
    final int value = sendBuffer;
    return value == -1 ? null : option.cast(Integer.valueOf(value));
  } else if (option == Options.KEEP_ALIVE) {
    return option.cast(Boolean.valueOf(keepAlive != 0));
  } else if (option == Options.TCP_OOB_INLINE) {
    return option.cast(Boolean.valueOf(oobInline != 0));
  } else if (option == Options.TCP_NODELAY) {
    return option.cast(Boolean.valueOf(tcpNoDelay != 0));
  } else if (option == Options.READ_TIMEOUT) {
    return option.cast(Integer.valueOf(readTimeout));
  } else if (option == Options.WRITE_TIMEOUT) {
    return option.cast(Integer.valueOf(writeTimeout));
  } else if (option == Options.CONNECTION_HIGH_WATER) {
    return option.cast(Integer.valueOf(getHighWater(connectionStatus)));
  } else if (option == Options.CONNECTION_LOW_WATER) {
    return option.cast(Integer.valueOf(getLowWater(connectionStatus)));
  } else {
    return null;
  }
}

代码示例来源:origin: wildfly/wildfly

public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException {
  final Object old;
  if (option == Options.REUSE_ADDRESSES) {
    old = Boolean.valueOf(socket.getReuseAddress());
    socket.setReuseAddress(Options.REUSE_ADDRESSES.cast(value, Boolean.FALSE).booleanValue());
  } else if (option == Options.RECEIVE_BUFFER) {

代码示例来源:origin: wildfly/wildfly

public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException {
  final Object old;
  if (option == Options.REUSE_ADDRESSES) {
    old = Boolean.valueOf(socket.getReuseAddress());
    socket.setReuseAddress(Options.REUSE_ADDRESSES.cast(value, Boolean.FALSE).booleanValue());
  } else if (option == Options.RECEIVE_BUFFER) {

代码示例来源:origin: jitsi/ice4j

/**
 * {@inheritDoc}
 *
 * Forwards to {@link #delegate}.
 */
@Override
public boolean getReuseAddress()
  throws SocketException
{
  return delegate.getReuseAddress();
}

代码示例来源:origin: org.apache.hbase.thirdparty/hbase-shaded-netty

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: apache/activemq-artemis

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: apache/activemq-artemis

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: io.bitsensor/proto

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public boolean isReuseAddress() {
  try {
    return javaSocket.getReuseAddress();
  } catch (SocketException e) {
    throw new ChannelException(e);
  }
}

代码示例来源:origin: EvoSuite/evosuite

@Override
public boolean getReuseAddress() throws SocketException {
  if(!MockFramework.isEnabled()){
    return super.getReuseAddress();
  }
  if (isClosed())
    throw new SocketException("Socket is closed");
  return ((Boolean) (getImpl().getOption(SocketOptions.SO_REUSEADDR))).booleanValue();
}

相关文章