java.net.Socket.getTcpNoDelay()方法的使用及代码示例

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

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

Socket.getTcpNoDelay介绍

[英]Returns this socket's SocketOptions#TCP_NODELAY setting.
[中]返回此套接字的SocketOptions#TCP#节点延迟设置。

代码示例

代码示例来源:origin: aws/aws-sdk-java

@Override
public boolean getTcpNoDelay() throws SocketException {
  return sock.getTcpNoDelay();
}

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

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

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

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

代码示例来源:origin: apache/zookeeper

/**
 * See {@link Socket#getTcpNoDelay()}. Calling this method does not trigger mode detection.
 */
@Override
public boolean getTcpNoDelay() throws SocketException {
  return getSocketAllowUnknownMode().getTcpNoDelay();
}

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

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

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

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

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

public <T> T getOption(final Option<T> option) throws IOException {
  if (option == Options.CLOSE_ABORT) {
    return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getSoLinger() == 0));
  } else if (option == Options.IP_TRAFFIC_CLASS) {
    return option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getTrafficClass()));
  } else if (option == Options.KEEP_ALIVE) {
    return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getKeepAlive()));
  } else if (option == Options.READ_TIMEOUT) {
    return option.cast(Integer.valueOf(conduit.getReadTimeout()));
  } else if (option == Options.RECEIVE_BUFFER) {
    return option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getReceiveBufferSize()));
  } else if (option == Options.SEND_BUFFER) {
    return option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getSendBufferSize()));
  } else if (option == Options.TCP_NODELAY) {
    return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getTcpNoDelay()));
  } else if (option == Options.TCP_OOB_INLINE) {
    return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getOOBInline()));
  } else if (option == Options.WRITE_TIMEOUT) {
    return option.cast(Integer.valueOf(conduit.getWriteTimeout()));
  } else {
    return null;
  }
}

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

conduit.getSocketChannel().socket().setSendBufferSize(Options.SEND_BUFFER.cast(value).intValue());
} else if (option == Options.TCP_NODELAY) {
  result = option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getTcpNoDelay()));
  conduit.getSocketChannel().socket().setTcpNoDelay(Options.TCP_NODELAY.cast(value, Boolean.FALSE).booleanValue());
} else if (option == Options.TCP_OOB_INLINE) {

代码示例来源:origin: apache/ignite

@Nullable @Override public Object call() throws Exception {
    Socket sock = null;
    try {
      sock = new Socket(addr, 60000);
      X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() +
        ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() +
        ", NODELAY=" + sock.getTcpNoDelay() + ']');
      sock.setTcpNoDelay(true);
      X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() +
        ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() +
        ", NODELAY=" + sock.getTcpNoDelay() + ']');
      Thread.sleep(10000);
      return null;
    }
    finally {
      U.closeQuiet(sock);
    }
  }
},

代码示例来源:origin: apache/zookeeper

@Override
  public void run() {
    try {
      byte[] buf = new byte[1024];
      int bytesRead = unifiedSocket.getInputStream().read(buf, 0, 1024);
      // Make sure the settings applied above before the socket was potentially upgraded to
      // TLS still apply.
      Assert.assertEquals(tcpNoDelay, unifiedSocket.getTcpNoDelay());
      Assert.assertEquals(TIMEOUT, unifiedSocket.getSoTimeout());
      Assert.assertEquals(keepAlive, unifiedSocket.getKeepAlive());
      if (bytesRead > 0) {
        byte[] dataFromClient = new byte[bytesRead];
        System.arraycopy(buf, 0, dataFromClient, 0, bytesRead);
        synchronized (dataFromClients) {
          dataFromClients.add(dataFromClient);
        }
      }
      unifiedSocket.getOutputStream().write(dataToClient);
      unifiedSocket.getOutputStream().flush();
    } catch (IOException e) {
      throw new RuntimeException(e);
    } finally {
      forceClose(unifiedSocket);
    }
  }
});

代码示例来源:origin: apache/ignite

@Nullable @Override public Object call() throws Exception {
    ServerSocket srvSock = null;
    Socket sock = null;
    try {
      srvSock = new ServerSocket(60000, 0, addr);
      sock = srvSock.accept();
      X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() +
        ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() +
        ", NODELAY=" + sock.getTcpNoDelay() + ']');
      sock.setSoTimeout(2000);
      sock.setTcpNoDelay(true);
      X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() +
        ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() +
        ", NODELAY=" + sock.getTcpNoDelay() + ']');
      sock.getInputStream().read();
    }
    catch (IOException e) {
      X.println("Caught expected exception: " + e);
      e.printStackTrace();
    }
    finally {
      U.closeQuiet(srvSock);
      U.closeQuiet(sock);
    }
    return null;
  }
},

代码示例来源:origin: stackoverflow.com

return delegate.getTcpNoDelay();

代码示例来源:origin: stackoverflow.com

return delegate.getTcpNoDelay();

代码示例来源:origin: stackoverflow.com

return delegate.getTcpNoDelay();

代码示例来源:origin: commons-net/commons-net

/**
 * Returns true if Nagle's algorithm is enabled on the currently opened
 * socket.
 * <p>
 * @return True if Nagle's algorithm is enabled on the currently opened
 *        socket, false otherwise.
 * @throws SocketException If the operation fails.
 * @throws NullPointerException if the socket is not currently open
 */
public boolean getTcpNoDelay() throws SocketException
{
  return _socket_.getTcpNoDelay();
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public boolean getTcpNoDelay() throws SocketException {
  return socket.getTcpNoDelay();
}

代码示例来源:origin: com.sun.mail/javax.mail

@Override
public boolean getTcpNoDelay() throws SocketException {
  return socket.getTcpNoDelay();
}

代码示例来源:origin: apache/mina

/**
 * {@inheritDoc}
 */
@Override
public Boolean isTcpNoDelay() {
  try {
    return socket.getTcpNoDelay();
  } catch (SocketException e) {
    throw new ConfigurationException(e);
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

Assert.assertEquals(false, socket.getTcpNoDelay());

代码示例来源:origin: org.apache.logging.log4j/log4j-core

Assert.assertEquals(false, socket.getOOBInline());
Assert.assertEquals(false, socket.getReuseAddress());
Assert.assertEquals(false, socket.getTcpNoDelay());

相关文章

微信公众号

最新文章

更多