当前位置: 首页>>代码示例>>Java>>正文


Java ServerSocket.setReceiveBufferSize方法代码示例

本文整理汇总了Java中java.net.ServerSocket.setReceiveBufferSize方法的典型用法代码示例。如果您正苦于以下问题:Java ServerSocket.setReceiveBufferSize方法的具体用法?Java ServerSocket.setReceiveBufferSize怎么用?Java ServerSocket.setReceiveBufferSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.ServerSocket的用法示例。


在下文中一共展示了ServerSocket.setReceiveBufferSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import java.net.ServerSocket; //导入方法依赖的package包/类
private void init() {

        ServerSocketChannel socketChannel = processor.javaChannel();

        ServerSocket javaSocket = socketChannel.socket();

        try {
            if (serverConfig.getReceiveBufferSize() != null) {
                javaSocket.setReceiveBufferSize(serverConfig.getReceiveBufferSize());
            }
            if (serverConfig.getReuseAddress() != null) {
                javaSocket.setReuseAddress(serverConfig.getReuseAddress());
            }
        } catch (SocketException e) {
            throw new NioException("config channel error:" + e.getMessage(), e);
        }
    }
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:18,代码来源:NioServer.java

示例2: createServerSocket

import java.net.ServerSocket; //导入方法依赖的package包/类
public ServerSocket createServerSocket(int nport, int backlog, InetAddress bindAddr,
    List<GatewayTransportFilter> transportFilters, int socketBufferSize) throws IOException {
  if (transportFilters.isEmpty()) {
    return createServerSocket(nport, backlog, bindAddr, socketBufferSize);
  } else {
    printConfig();
    ServerSocket result = new TransportFilterServerSocket(transportFilters);
    result.setReuseAddress(true);
    // Set the receive buffer size before binding the socket so
    // that large buffers will be allocated on accepted sockets (see
    // java.net.ServerSocket.setReceiverBufferSize javadocs)
    result.setReceiveBufferSize(socketBufferSize);
    try {
      result.bind(new InetSocketAddress(bindAddr, nport), backlog);
    } catch (BindException e) {
      BindException throwMe =
          new BindException(LocalizedStrings.SocketCreator_FAILED_TO_CREATE_SERVER_SOCKET_ON_0_1
              .toLocalizedString(new Object[] {bindAddr, Integer.valueOf(nport)}));
      throwMe.initCause(e);
      throw throwMe;
    }
    return result;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:SocketCreator.java

示例3: setProperties

import java.net.ServerSocket; //导入方法依赖的package包/类
public void setProperties(ServerSocket socket) throws SocketException{
    if (rxBufSize != null)
        socket.setReceiveBufferSize(rxBufSize.intValue());
    if (performanceConnectionTime != null && performanceLatency != null &&
            performanceBandwidth != null)
        socket.setPerformancePreferences(
                performanceConnectionTime.intValue(),
                performanceLatency.intValue(),
                performanceBandwidth.intValue());
    if (soReuseAddress != null)
        socket.setReuseAddress(soReuseAddress.booleanValue());
    if (soTimeout != null && soTimeout.intValue() >= 0)
        socket.setSoTimeout(soTimeout.intValue());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:SocketProperties.java

示例4: bound

import java.net.ServerSocket; //导入方法依赖的package包/类
/** Creates a new instance of AEServerSocket. This Thread must be started to serve connections.
@throws java.net.BindException when the socket is already bound (probably by another viewer)
 */
public AEServerSocket() throws java.io.IOException {
    T = this;
    serverSocket = new ServerSocket();
    serverSocket.setReceiveBufferSize(receiveBufferSize);
    /*}catch(java.net.BindException be){
    log.warning("server socket already bound to port (probably from another AEViewer)");
     */
    setName("AEServerSocket port=" + port);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:13,代码来源:AEServerSocket.java

示例5: setProperties

import java.net.ServerSocket; //导入方法依赖的package包/类
public void setProperties(ServerSocket socket) throws SocketException {
	if (rxBufSize != null)
		socket.setReceiveBufferSize(rxBufSize.intValue());
	if (performanceConnectionTime != null && performanceLatency != null && performanceBandwidth != null)
		socket.setPerformancePreferences(performanceConnectionTime.intValue(), performanceLatency.intValue(),
				performanceBandwidth.intValue());
	if (soReuseAddress != null)
		socket.setReuseAddress(soReuseAddress.booleanValue());
	if (soTimeout != null && soTimeout.intValue() >= 0)
		socket.setSoTimeout(soTimeout.intValue());
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:SocketProperties.java


注:本文中的java.net.ServerSocket.setReceiveBufferSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。