Java Code Examples for java.net.Socket.setReceiveBufferSize()

The following are Jave code examples for showing how to use setReceiveBufferSize() of the java.net.Socket class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pooled-jms   File: SocketProxy.java   View Source Code Vote up 6 votes
public void run() {
    try {
        while (!socket.isClosed()) {
            pause.get().await();
            try {
                Socket source = socket.accept();
                pause.get().await();
                if (receiveBufferSize > 0) {
                    source.setReceiveBufferSize(receiveBufferSize);
                }
                LOG.info("accepted " + source + ", receiveBufferSize:" + source.getReceiveBufferSize());
                synchronized (connections) {
                    connections.add(new Bridge(source, target));
                }
            } catch (SocketTimeoutException expected) {
            }
        }
    } catch (Exception e) {
        LOG.debug("acceptor: finished for reason: " + e.getLocalizedMessage());
    }
}
 
Example 2
Project: pooled-jms   File: SocketProxy.java   View Source Code Vote up 6 votes
@Override
public void run() {
          try {
              while (!socket.isClosed()) {
                  pause.get().await();
                  try {
                      Socket source = socket.accept();
                      pause.get().await();
                      if (receiveBufferSize > 0) {
                          source.setReceiveBufferSize(receiveBufferSize);
                      }
                      LOG.info("accepted " + source + ", receiveBufferSize:" + source.getReceiveBufferSize());
                      synchronized (connections) {
                          connections.add(new Bridge(source, target));
                      }
                  } catch (SocketTimeoutException expected) {
                  }
              }
          } catch (Exception e) {
              LOG.debug("acceptor: finished for reason: " + e.getLocalizedMessage());
          }
      }
 
Example 3
Project: cyberduck   File: DefaultSocketConfigurator.java   View Source Code Vote up 6 votes
@Override
public void configure(final Socket socket) throws IOException {
    if(preferences.getInteger("connection.buffer.receive") > 0) {
        socket.setReceiveBufferSize(preferences.getInteger("connection.buffer.receive"));
    }
    if(preferences.getInteger("connection.buffer.send") > 0) {
        socket.setSendBufferSize(preferences.getInteger("connection.buffer.send"));
    }
    final int timeout = preferences.getInteger("connection.timeout.seconds") * 1000;
    if(log.isInfoEnabled()) {
        log.info(String.format("Set timeout to %dms for socket %s", timeout, socket));
    }
    socket.setSoTimeout(timeout);
    if(preferences.getBoolean("connection.socket.linger")) {
        // The setting only affects socket close. Make sure closing SSL socket does not hang because close_notify cannot be sent.
        socket.setSoLinger(true, timeout);
    }
    if(preferences.getBoolean("connection.socket.keepalive")) {
        socket.setKeepAlive(true);
    }
}
 
Example 4
Project: apache-tomcat-7.0.73-with-comment   File: SocketProperties.java   View Source Code Vote up 6 votes
public void setProperties(Socket socket) throws SocketException{
    if (rxBufSize != null)
        socket.setReceiveBufferSize(rxBufSize.intValue());
    if (txBufSize != null)
        socket.setSendBufferSize(txBufSize.intValue());
    if (ooBInline !=null)
        socket.setOOBInline(ooBInline.booleanValue());
    if (soKeepAlive != null)
        socket.setKeepAlive(soKeepAlive.booleanValue());
    if (performanceConnectionTime != null && performanceLatency != null &&
            performanceBandwidth != null)
        socket.setPerformancePreferences(
                performanceConnectionTime.intValue(),
                performanceLatency.intValue(),
                performanceBandwidth.intValue());
    if (soReuseAddress != null)
        socket.setReuseAddress(soReuseAddress.booleanValue());
    if (soLingerOn != null && soLingerTime != null)
        socket.setSoLinger(soLingerOn.booleanValue(),
                soLingerTime.intValue());
    if (soTimeout != null && soTimeout.intValue() >= 0)
        socket.setSoTimeout(soTimeout.intValue());
    if (tcpNoDelay != null)
        socket.setTcpNoDelay(tcpNoDelay.booleanValue());
}
 
Example 5
Project: jdk8u-jdk   File: SetReceiveBufferSize.java   View Source Code Vote up 6 votes
public SetReceiveBufferSize() throws Exception {
    ServerSocket ss = new ServerSocket(0);
    Socket s = new Socket("localhost", ss.getLocalPort());
    Socket accepted = ss.accept();
    try {
        s.setReceiveBufferSize(0);
    } catch (IllegalArgumentException e) {
        return;
    } catch (Exception ex) {
    } finally {
        ss.close();
        s.close();
        accepted.close();
    }
    throw new RuntimeException("IllegalArgumentException not thrown!");
}
 
Example 6
Project: java-android-websocket-client   File: RequestListener.java   View Source Code Vote up 6 votes
@Override
public void run() {
    try {
        while (!isTerminated() && !Thread.interrupted()) {
            final Socket socket = this.serversocket.accept();
            socket.setSoTimeout(this.socketConfig.getSoTimeout());
            socket.setKeepAlive(this.socketConfig.isSoKeepAlive());
            socket.setTcpNoDelay(this.socketConfig.isTcpNoDelay());
            if (this.socketConfig.getRcvBufSize() > 0) {
                socket.setReceiveBufferSize(this.socketConfig.getRcvBufSize());
            }
            if (this.socketConfig.getSndBufSize() > 0) {
                socket.setSendBufferSize(this.socketConfig.getSndBufSize());
            }
            if (this.socketConfig.getSoLinger() >= 0) {
                socket.setSoLinger(true, this.socketConfig.getSoLinger());
            }
            final HttpServerConnection conn = this.connectionFactory.createConnection(socket);
            final Worker worker = new Worker(this.httpService, conn, this.exceptionLogger);
            this.executorService.execute(worker);
        }
    } catch (final Exception ex) {
        this.exceptionLogger.log(ex);
    }
}
 
Example 7
Project: openjdk-jdk10   File: SetReceiveBufferSize.java   View Source Code Vote up 6 votes
public SetReceiveBufferSize() throws Exception {
    ServerSocket ss = new ServerSocket(0);
    Socket s = new Socket("localhost", ss.getLocalPort());
    Socket accepted = ss.accept();
    try {
        s.setReceiveBufferSize(0);
    } catch (IllegalArgumentException e) {
        return;
    } catch (Exception ex) {
    } finally {
        ss.close();
        s.close();
        accepted.close();
    }
    throw new RuntimeException("IllegalArgumentException not thrown!");
}
 
Example 8
Project: CrawlerSYS   File: NodeReceiveThread.java   View Source Code Vote up 5 votes
public NodeReceiveThread(Socket sk) {
		super();
		this.sk = sk;
		try {
			sk.setSendBufferSize(1024*1024);
			sk.setReceiveBufferSize(1024*1024);
			out = new ObjectOutputStream(sk.getOutputStream());
			in = new ObjectInputStream(sk.getInputStream());
		} catch (IOException e) {
			// TODO Auto-generated catch block
e.printStackTrace();logger.error("Exception",e);
		}
	}
 
Example 9
Project: elasticsearch_my   File: MockTcpTransport.java   View Source Code Vote up 5 votes
private void configureSocket(Socket socket) throws SocketException {
    socket.setTcpNoDelay(TCP_NO_DELAY.get(settings));
    ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings);
    if (tcpSendBufferSize.getBytes() > 0) {
        socket.setSendBufferSize(tcpSendBufferSize.bytesAsInt());
    }
    ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings);
    if (tcpReceiveBufferSize.getBytes() > 0) {
        socket.setReceiveBufferSize(tcpReceiveBufferSize.bytesAsInt());
    }
    socket.setReuseAddress(TCP_REUSE_ADDRESS.get(settings));
}
 
Example 10
Project: tomcat7   File: BioReceiver.java   View Source Code Vote up 5 votes
public void listen() throws Exception {
    if (doListen()) {
        log.warn("ServerSocket already started");
        return;
    }
    setListen(true);

    while ( doListen() ) {
        Socket socket = null;
        if ( getTaskPool().available() < 1 ) {
            if ( log.isWarnEnabled() )
                log.warn("All BIO server replication threads are busy, unable to handle more requests until a thread is freed up.");
        }
        BioReplicationTask task = (BioReplicationTask)getTaskPool().getRxTask();
        if ( task == null ) continue; //should never happen
        try {
            socket = serverSocket.accept();
        }catch ( Exception x ) {
            if ( doListen() ) throw x;
        }
        if ( !doListen() ) {
            task.setDoRun(false);
            task.serviceSocket(null,null);
            getExecutor().execute(task);
            break; //regular shutdown
        }
        if ( socket == null ) continue;
        socket.setReceiveBufferSize(getRxBufSize());
        socket.setSendBufferSize(getTxBufSize());
        socket.setTcpNoDelay(getTcpNoDelay());
        socket.setKeepAlive(getSoKeepAlive());
        socket.setOOBInline(getOoBInline());
        socket.setReuseAddress(getSoReuseAddress());
        socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
        socket.setSoTimeout(getTimeout());
        ObjectReader reader = new ObjectReader(socket);
        task.serviceSocket(socket,reader);
        getExecutor().execute(task);
    }//while
}
 
Example 11
Project: tomcat7   File: BioSender.java   View Source Code Vote up 5 votes
/**
 * open real socket and set time out when waitForAck is enabled
 * is socket open return directly
 */
protected void openSocket() throws IOException {
   if(isConnected()) return ;
   try {
       socket = new Socket();
       InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
       socket.connect(sockaddr,(int)getTimeout());
       socket.setSendBufferSize(getTxBufSize());
       socket.setReceiveBufferSize(getRxBufSize());
       socket.setSoTimeout( (int) getTimeout());
       socket.setTcpNoDelay(getTcpNoDelay());
       socket.setKeepAlive(getSoKeepAlive());
       socket.setReuseAddress(getSoReuseAddress());
       socket.setOOBInline(getOoBInline());
       socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
       socket.setTrafficClass(getSoTrafficClass());
       setConnected(true);
       soOut = socket.getOutputStream();
       soIn  = socket.getInputStream();
       setRequestCount(0);
       setConnectTime(System.currentTimeMillis());
       if (log.isDebugEnabled())
           log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(), Integer.valueOf(getPort()), Long.valueOf(0)));
  } catch (IOException ex1) {
      SenderState.getSenderState(getDestination()).setSuspect();
      if (log.isDebugEnabled())
          log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), Integer.valueOf(getPort()), Long.valueOf(0)), ex1);
      throw (ex1);
    }
    
 }
 
Example 12
Project: lazycat   File: BioSender.java   View Source Code Vote up 5 votes
/**
 * open real socket and set time out when waitForAck is enabled is socket
 * open return directly
 */
protected void openSocket() throws IOException {
	if (isConnected())
		return;
	try {
		socket = new Socket();
		InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
		socket.connect(sockaddr, (int) getTimeout());
		socket.setSendBufferSize(getTxBufSize());
		socket.setReceiveBufferSize(getRxBufSize());
		socket.setSoTimeout((int) getTimeout());
		socket.setTcpNoDelay(getTcpNoDelay());
		socket.setKeepAlive(getSoKeepAlive());
		socket.setReuseAddress(getSoReuseAddress());
		socket.setOOBInline(getOoBInline());
		socket.setSoLinger(getSoLingerOn(), getSoLingerTime());
		socket.setTrafficClass(getSoTrafficClass());
		setConnected(true);
		soOut = socket.getOutputStream();
		soIn = socket.getInputStream();
		setRequestCount(0);
		setConnectTime(System.currentTimeMillis());
		if (log.isDebugEnabled())
			log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(),
					Integer.valueOf(getPort()), Long.valueOf(0)));
	} catch (IOException ex1) {
		SenderState.getSenderState(getDestination()).setSuspect();
		if (log.isDebugEnabled())
			log.debug(sm.getString("IDataSender.openSocket.failure", getAddress().getHostAddress(),
					Integer.valueOf(getPort()), Long.valueOf(0)), ex1);
		throw (ex1);
	}

}
 
Example 13
Project: the-vigilantes   File: StandardSocketFactory.java   View Source Code Vote up 5 votes
/**
 * Configures socket properties based on properties from the connection
 * (tcpNoDelay, snd/rcv buf, traffic class, etc).
 * 
 * @param props
 * @throws SocketException
 * @throws IOException
 */
private void configureSocket(Socket sock, Properties props) throws SocketException, IOException {
    sock.setTcpNoDelay(Boolean.valueOf(props.getProperty(TCP_NO_DELAY_PROPERTY_NAME, TCP_NO_DELAY_DEFAULT_VALUE)).booleanValue());

    String keepAlive = props.getProperty(TCP_KEEP_ALIVE_PROPERTY_NAME, TCP_KEEP_ALIVE_DEFAULT_VALUE);

    if (keepAlive != null && keepAlive.length() > 0) {
        sock.setKeepAlive(Boolean.valueOf(keepAlive).booleanValue());
    }

    int receiveBufferSize = Integer.parseInt(props.getProperty(TCP_RCV_BUF_PROPERTY_NAME, TCP_RCV_BUF_DEFAULT_VALUE));

    if (receiveBufferSize > 0) {
        sock.setReceiveBufferSize(receiveBufferSize);
    }

    int sendBufferSize = Integer.parseInt(props.getProperty(TCP_SND_BUF_PROPERTY_NAME, TCP_SND_BUF_DEFAULT_VALUE));

    if (sendBufferSize > 0) {
        sock.setSendBufferSize(sendBufferSize);
    }

    int trafficClass = Integer.parseInt(props.getProperty(TCP_TRAFFIC_CLASS_PROPERTY_NAME, TCP_TRAFFIC_CLASS_DEFAULT_VALUE));

    if (trafficClass > 0) {
        sock.setTrafficClass(trafficClass);
    }
}
 
Example 14
Project: lams   File: StandardSocketFactory.java   View Source Code Vote up 5 votes
/**
 * Configures socket properties based on properties from the connection
 * (tcpNoDelay, snd/rcv buf, traffic class, etc).
 * 
 * @param props
 * @throws SocketException
 * @throws IOException
 */
private void configureSocket(Socket sock, Properties props) throws SocketException, IOException {
    sock.setTcpNoDelay(Boolean.valueOf(props.getProperty(TCP_NO_DELAY_PROPERTY_NAME, TCP_NO_DELAY_DEFAULT_VALUE)).booleanValue());

    String keepAlive = props.getProperty(TCP_KEEP_ALIVE_PROPERTY_NAME, TCP_KEEP_ALIVE_DEFAULT_VALUE);

    if (keepAlive != null && keepAlive.length() > 0) {
        sock.setKeepAlive(Boolean.valueOf(keepAlive).booleanValue());
    }

    int receiveBufferSize = Integer.parseInt(props.getProperty(TCP_RCV_BUF_PROPERTY_NAME, TCP_RCV_BUF_DEFAULT_VALUE));

    if (receiveBufferSize > 0) {
        sock.setReceiveBufferSize(receiveBufferSize);
    }

    int sendBufferSize = Integer.parseInt(props.getProperty(TCP_SND_BUF_PROPERTY_NAME, TCP_SND_BUF_DEFAULT_VALUE));

    if (sendBufferSize > 0) {
        sock.setSendBufferSize(sendBufferSize);
    }

    int trafficClass = Integer.parseInt(props.getProperty(TCP_TRAFFIC_CLASS_PROPERTY_NAME, TCP_TRAFFIC_CLASS_DEFAULT_VALUE));

    if (trafficClass > 0) {
        sock.setTrafficClass(trafficClass);
    }
}
 
Example 15
Project: ProyectoPacientes   File: StandardSocketFactory.java   View Source Code Vote up 5 votes
/**
 * Configures socket properties based on properties from the connection
 * (tcpNoDelay, snd/rcv buf, traffic class, etc).
 * 
 * @param props
 * @throws SocketException
 * @throws IOException
 */
private void configureSocket(Socket sock, Properties props) throws SocketException, IOException {
    sock.setTcpNoDelay(Boolean.valueOf(props.getProperty(TCP_NO_DELAY_PROPERTY_NAME, TCP_NO_DELAY_DEFAULT_VALUE)).booleanValue());

    String keepAlive = props.getProperty(TCP_KEEP_ALIVE_PROPERTY_NAME, TCP_KEEP_ALIVE_DEFAULT_VALUE);

    if (keepAlive != null && keepAlive.length() > 0) {
        sock.setKeepAlive(Boolean.valueOf(keepAlive).booleanValue());
    }

    int receiveBufferSize = Integer.parseInt(props.getProperty(TCP_RCV_BUF_PROPERTY_NAME, TCP_RCV_BUF_DEFAULT_VALUE));

    if (receiveBufferSize > 0) {
        sock.setReceiveBufferSize(receiveBufferSize);
    }

    int sendBufferSize = Integer.parseInt(props.getProperty(TCP_SND_BUF_PROPERTY_NAME, TCP_SND_BUF_DEFAULT_VALUE));

    if (sendBufferSize > 0) {
        sock.setSendBufferSize(sendBufferSize);
    }

    int trafficClass = Integer.parseInt(props.getProperty(TCP_TRAFFIC_CLASS_PROPERTY_NAME, TCP_TRAFFIC_CLASS_DEFAULT_VALUE));

    if (trafficClass > 0) {
        sock.setTrafficClass(trafficClass);
    }
}
 
Example 16
Project: BibliotecaPS   File: StandardSocketFactory.java   View Source Code Vote up 5 votes
/**
 * Configures socket properties based on properties from the connection
 * (tcpNoDelay, snd/rcv buf, traffic class, etc).
 * 
 * @param props
 * @throws SocketException
 * @throws IOException
 */
private void configureSocket(Socket sock, Properties props) throws SocketException, IOException {
    sock.setTcpNoDelay(Boolean.valueOf(props.getProperty(TCP_NO_DELAY_PROPERTY_NAME, TCP_NO_DELAY_DEFAULT_VALUE)).booleanValue());

    String keepAlive = props.getProperty(TCP_KEEP_ALIVE_PROPERTY_NAME, TCP_KEEP_ALIVE_DEFAULT_VALUE);

    if (keepAlive != null && keepAlive.length() > 0) {
        sock.setKeepAlive(Boolean.valueOf(keepAlive).booleanValue());
    }

    int receiveBufferSize = Integer.parseInt(props.getProperty(TCP_RCV_BUF_PROPERTY_NAME, TCP_RCV_BUF_DEFAULT_VALUE));

    if (receiveBufferSize > 0) {
        sock.setReceiveBufferSize(receiveBufferSize);
    }

    int sendBufferSize = Integer.parseInt(props.getProperty(TCP_SND_BUF_PROPERTY_NAME, TCP_SND_BUF_DEFAULT_VALUE));

    if (sendBufferSize > 0) {
        sock.setSendBufferSize(sendBufferSize);
    }

    int trafficClass = Integer.parseInt(props.getProperty(TCP_TRAFFIC_CLASS_PROPERTY_NAME, TCP_TRAFFIC_CLASS_DEFAULT_VALUE));

    if (trafficClass > 0) {
        sock.setTrafficClass(trafficClass);
    }
}
 
Example 17
Project: apache-tomcat-7.0.73-with-comment   File: BioReceiver.java   View Source Code Vote up 5 votes
public void listen() throws Exception {
    if (doListen()) {
        log.warn("ServerSocket already started");
        return;
    }
    setListen(true);

    while ( doListen() ) {
        Socket socket = null;
        if ( getTaskPool().available() < 1 ) {
            if ( log.isWarnEnabled() )
                log.warn("All BIO server replication threads are busy, unable to handle more requests until a thread is freed up.");
        }
        BioReplicationTask task = (BioReplicationTask)getTaskPool().getRxTask();
        if ( task == null ) continue; //should never happen
        try {
            socket = serverSocket.accept();
        }catch ( Exception x ) {
            if ( doListen() ) throw x;
        }
        if ( !doListen() ) {
            task.setDoRun(false);
            task.serviceSocket(null,null);
            getExecutor().execute(task);
            break; //regular shutdown
        }
        if ( socket == null ) continue;
        socket.setReceiveBufferSize(getRxBufSize());
        socket.setSendBufferSize(getTxBufSize());
        socket.setTcpNoDelay(getTcpNoDelay());
        socket.setKeepAlive(getSoKeepAlive());
        socket.setOOBInline(getOoBInline());
        socket.setReuseAddress(getSoReuseAddress());
        socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
        socket.setSoTimeout(getTimeout());
        ObjectReader reader = new ObjectReader(socket);
        task.serviceSocket(socket,reader);
        getExecutor().execute(task);
    }//while
}
 
Example 18
Project: apache-tomcat-7.0.73-with-comment   File: BioSender.java   View Source Code Vote up 5 votes
/**
 * open real socket and set time out when waitForAck is enabled
 * is socket open return directly
 */
protected void openSocket() throws IOException {
   if(isConnected()) return ;
   try {
       socket = new Socket();
       InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
       socket.connect(sockaddr,(int)getTimeout());
       socket.setSendBufferSize(getTxBufSize());
       socket.setReceiveBufferSize(getRxBufSize());
       socket.setSoTimeout( (int) getTimeout());
       socket.setTcpNoDelay(getTcpNoDelay());
       socket.setKeepAlive(getSoKeepAlive());
       socket.setReuseAddress(getSoReuseAddress());
       socket.setOOBInline(getOoBInline());
       socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
       socket.setTrafficClass(getSoTrafficClass());
       setConnected(true);
       soOut = socket.getOutputStream();
       soIn  = socket.getInputStream();
       setRequestCount(0);
       setConnectTime(System.currentTimeMillis());
       if (log.isDebugEnabled())
           log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(), Integer.valueOf(getPort()), Long.valueOf(0)));
  } catch (IOException ex1) {
      SenderState.getSenderState(getDestination()).setSuspect();
      if (log.isDebugEnabled())
          log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), Integer.valueOf(getPort()), Long.valueOf(0)), ex1);
      throw (ex1);
    }
    
 }
 
Example 19
Project: java-android-websocket-client   File: BasicConnFactory.java   View Source Code Vote up 5 votes
@Override
public HttpClientConnection create(final HttpHost host) throws IOException {
    final String scheme = host.getSchemeName();
    Socket socket = null;
    if ("http".equalsIgnoreCase(scheme)) {
        socket = this.plainfactory != null ? this.plainfactory.createSocket() :
                new Socket();
    } if ("https".equalsIgnoreCase(scheme)) {
        socket = (this.sslfactory != null ? this.sslfactory :
                SSLSocketFactory.getDefault()).createSocket();
    }
    if (socket == null) {
        throw new IOException(scheme + " scheme is not supported");
    }
    final String hostname = host.getHostName();
    int port = host.getPort();
    if (port == -1) {
        if (host.getSchemeName().equalsIgnoreCase("http")) {
            port = 80;
        } else if (host.getSchemeName().equalsIgnoreCase("https")) {
            port = 443;
        }
    }
    socket.setSoTimeout(this.sconfig.getSoTimeout());
    if (this.sconfig.getSndBufSize() > 0) {
        socket.setSendBufferSize(this.sconfig.getSndBufSize());
    }
    if (this.sconfig.getRcvBufSize() > 0) {
        socket.setReceiveBufferSize(this.sconfig.getRcvBufSize());
    }
    socket.setTcpNoDelay(this.sconfig.isTcpNoDelay());
    final int linger = this.sconfig.getSoLinger();
    if (linger >= 0) {
        socket.setSoLinger(true, linger);
    }
    socket.setKeepAlive(this.sconfig.isSoKeepAlive());
    socket.connect(new InetSocketAddress(hostname, port), this.connectTimeout);
    return this.connFactory.createConnection(socket);
}
 
Example 20
Project: lazycat   File: BioReceiver.java   View Source Code Vote up 4 votes
public void listen() throws Exception {
	if (doListen()) {
		log.warn("ServerSocket already started");
		return;
	}
	setListen(true);

	while (doListen()) {
		Socket socket = null;
		if (getTaskPool().available() < 1) {
			if (log.isWarnEnabled())
				log.warn(
						"All BIO server replication threads are busy, unable to handle more requests until a thread is freed up.");
		}
		BioReplicationTask task = (BioReplicationTask) getTaskPool().getRxTask();
		if (task == null)
			continue; // should never happen
		try {
			socket = serverSocket.accept();
		} catch (Exception x) {
			if (doListen())
				throw x;
		}
		if (!doListen()) {
			task.setDoRun(false);
			task.serviceSocket(null, null);
			getExecutor().execute(task);
			break; // regular shutdown
		}
		if (socket == null)
			continue;
		socket.setReceiveBufferSize(getRxBufSize());
		socket.setSendBufferSize(getTxBufSize());
		socket.setTcpNoDelay(getTcpNoDelay());
		socket.setKeepAlive(getSoKeepAlive());
		socket.setOOBInline(getOoBInline());
		socket.setReuseAddress(getSoReuseAddress());
		socket.setSoLinger(getSoLingerOn(), getSoLingerTime());
		socket.setSoTimeout(getTimeout());
		ObjectReader reader = new ObjectReader(socket);
		task.serviceSocket(socket, reader);
		getExecutor().execute(task);
	} // while
}