本文整理了Java中java.nio.channels.SocketChannel.setOption()
方法的一些代码示例,展示了SocketChannel.setOption()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.setOption()
方法的具体详情如下:
包路径:java.nio.channels.SocketChannel
类名称:SocketChannel
方法名:setOption
暂无
代码示例来源:origin: apache/nifi
channel.setOption(StandardSocketOptions.SO_SNDBUF, maxSendBufferSize);
final int actualSendBufSize = channel.getOption(StandardSocketOptions.SO_SNDBUF);
if (actualSendBufSize < maxSendBufferSize) {
代码示例来源:origin: org.mongodb/mongo-java-driver
socketChannel.configureBlocking(false);
socketChannel.setOption(StandardSocketOptions.TCP_NODELAY, true);
socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
if (getSettings().getReceiveBufferSize() > 0) {
socketChannel.setOption(StandardSocketOptions.SO_RCVBUF, getSettings().getReceiveBufferSize());
socketChannel.setOption(StandardSocketOptions.SO_SNDBUF, getSettings().getSendBufferSize());
代码示例来源:origin: jitsi/ice4j
/**
* {@inheritDoc}
*
* Forwards to {@link #delegate} and returns {@code this}.
*/
@Override
public <U> SocketChannel setOption(SocketOption<U> name, U value)
throws IOException
{
delegate.setOption(name, value);
return this;
}
代码示例来源:origin: apache/asterixdb
public static void configure(SocketChannel sc) throws IOException {
sc.setOption(StandardSocketOptions.TCP_NODELAY, true);
sc.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
}
代码示例来源:origin: undera/jmeter-plugins
@Override
public <T> SocketChannel setOption(SocketOption<T> socketOption, T t) throws IOException {
return socketChannel.setOption(socketOption, t);
}
代码示例来源:origin: oci-pronghorn/Pronghorn
public static void initSocket(SocketChannel socket) throws IOException {
socket.configureBlocking(false);
socket.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
//TCP_NODELAY is required for HTTP/2 get used to to being on.
socket.setOption(StandardSocketOptions.TCP_NODELAY, true);
}
代码示例来源:origin: baratine/baratine
@Override
public void tcpNoDelay(boolean isNoDelay)
throws SocketException
{
try {
_channel.setOption(StandardSocketOptions.TCP_NODELAY, (Boolean) isNoDelay);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: zeebe-io/zeebe
public SocketChannel accept() {
try {
final SocketChannel socketChannel = media.accept();
socketChannel.setOption(StandardSocketOptions.TCP_NODELAY, true);
socketChannel.configureBlocking(false);
return socketChannel;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: io.zeebe/zb-transport
public SocketChannel accept() {
try {
final SocketChannel socketChannel = media.accept();
socketChannel.setOption(StandardSocketOptions.TCP_NODELAY, true);
socketChannel.configureBlocking(false);
return socketChannel;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: penberg/falcon
private static SocketChannel connect(String host, int port) throws Exception {
InetSocketAddress addr = new InetSocketAddress(host, port);
SocketChannel socket = SocketChannel.open();
socket.configureBlocking(false);
socket.setOption(TCP_NODELAY, true);
socket.connect(addr);
while (!socket.finishConnect());
return socket;
}
代码示例来源:origin: the8472/mldht
public PullMetaDataConnection(byte[] infoHash, InetSocketAddress dest) throws IOException {
this.infoHash = infoHash;
this.remoteAddress = dest;
channel = SocketChannel.open();
//channel.socket().setReuseAddress(true);
channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.configureBlocking(false);
//channel.bind(new InetSocketAddress(49002));
setState(STATE_INITIAL, STATE_CONNECTING);
sendBTHandshake();
}
代码示例来源:origin: paritytrading/parity
public Session accept() throws IOException {
SocketChannel channel = serverChannel.accept();
if (channel == null)
return null;
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.configureBlocking(false);
return new Session(channel, books);
}
代码示例来源:origin: paritytrading/nassau
public static Client connect(SocketAddress address) throws IOException {
SocketChannel channel = SocketChannel.open();
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.connect(address);
channel.configureBlocking(false);
return new Client(channel);
}
代码示例来源:origin: paritytrading/nassau
public Session accept() throws IOException {
SocketChannel channel = serverChannel.accept();
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.configureBlocking(false);
return new Session(channel);
}
代码示例来源:origin: paritytrading/philadelphia
static Initiator open(SocketAddress address) throws IOException {
SocketChannel channel = SocketChannel.open();
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.connect(address);
channel.configureBlocking(false);
return new Initiator(channel);
}
代码示例来源:origin: paritytrading/philadelphia
Session accept() throws IOException {
SocketChannel channel = serverChannel.accept();
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.configureBlocking(false);
return new Session(channel);
}
代码示例来源:origin: real-logic/artio
private void configure(final SocketChannel channel) throws IOException
{
channel.setOption(TCP_NODELAY, true);
if (configuration.receiverSocketBufferSize() > 0)
{
channel.setOption(SO_RCVBUF, configuration.receiverSocketBufferSize());
}
if (configuration.senderSocketBufferSize() > 0)
{
channel.setOption(SO_SNDBUF, configuration.senderSocketBufferSize());
}
}
代码示例来源:origin: paritytrading/parity
SoupBinTCPClient create(POEClientListener listener,
SoupBinTCPClientStatusListener statusListener) throws IOException {
SocketChannel channel = SocketChannel.open();
channel.connect(address);
channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
channel.configureBlocking(false);
return new SoupBinTCPClient(channel, POE.MAX_OUTBOUND_MESSAGE_LENGTH,
new POEClientParser(listener), statusListener);
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
@Override
public void setSoLinger(int value) throws IOException {
if (isOpen()) {
getRawChannel().setOption(StandardSocketOptions.SO_LINGER, value);
}
}
代码示例来源:origin: MyCATApache/Mycat-NIO
@SuppressWarnings("unchecked")
public Connection make(SocketChannel channel) throws IOException {
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
// 子类完成具体连接创建工作
Connection c = makeConnection(channel);
// 设置连接的参数
NetSystem.getInstance().setSocketParams(c,true);
// 设置NIOHandler
c.setHandler(getNIOHandler());
return c;
}
}
内容来源于网络,如有侵权,请联系作者删除!