List of usage examples for java.net Socket setReceiveBufferSize
public synchronized void setReceiveBufferSize(int size) throws SocketException
From source file:org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory.java
/** * Sets socket attributes on the socket. * @param socket The socket.//from ww w.j av a 2s . c o m * @throws SocketException */ protected void setSocketAttributes(Socket socket) throws SocketException { if (this.soTimeout >= 0) { socket.setSoTimeout(this.soTimeout); } if (this.soSendBufferSize > 0) { socket.setSendBufferSize(this.soSendBufferSize); } if (this.soReceiveBufferSize > 0) { socket.setReceiveBufferSize(this.soReceiveBufferSize); } socket.setTcpNoDelay(this.soTcpNoDelay); if (this.soLinger >= 0) { socket.setSoLinger(true, this.soLinger); } if (this.soTrafficClass >= 0) { socket.setTrafficClass(this.soTrafficClass); } socket.setKeepAlive(this.soKeepAlive); }
From source file:voldemort.store.socket.SocketPoolableObjectFactory.java
/** * Create a socket for the given host/port *//*from w w w .j a v a 2s .c o m*/ public Object makeObject(Object key) throws Exception { SocketDestination dest = (SocketDestination) key; Socket socket = new Socket(); socket.setReceiveBufferSize(this.socketBufferSize); socket.setSendBufferSize(this.socketBufferSize); socket.setTcpNoDelay(true); socket.setSoTimeout(soTimeoutMs); socket.connect(new InetSocketAddress(dest.getHost(), dest.getPort())); recordSocketCreation(dest, socket); return new SocketAndStreams(socket); }
From source file:xbird.util.net.PoolableSocketChannelFactory.java
private static SocketChannel createSocketChannel(final SocketAddress sockAddr, final boolean blocking, final int rcvbufSize) { final SocketChannel ch; try {// w ww . j a va 2 s. co m ch = SocketChannel.open(); ch.configureBlocking(blocking); } catch (IOException e) { LOG.error("Failed to open SocketChannel.", e); throw new IllegalStateException(e); } final Socket sock = ch.socket(); if (rcvbufSize != -1) { try { sock.setReceiveBufferSize(rcvbufSize); } catch (SocketException e) { LOG.error("Failed to setReceiveBufferSize.", e); throw new IllegalStateException(e); } } final boolean connected; try { connected = ch.connect(sockAddr); } catch (IOException e) { LOG.error("Failed to connect socket: " + sockAddr, e); throw new IllegalStateException(e); } if (!connected) { throw new IllegalStateException("Failed to connect: " + sockAddr); } return ch; }