@Override public int getSendBufferSize() throws SocketException { return sock.getSendBufferSize(); }
/** * Gets the socket's sendBufferSize. * * @return the size of the buffer for the socket OutputStream, -1 if the value * has not been set and the socket has not been opened * * @throws SocketException if an error occurs while getting the socket value * * @see Socket#getSendBufferSize() */ public int getSendBufferSize() throws SocketException { if (socket == null) { return -1; } else { return socket.getSendBufferSize(); } }
@Override public int getSendBufferSize() { try { return javaSocket.getSendBufferSize(); } catch (SocketException e) { throw new ChannelException(e); } }
@Override public int getSendBufferSize() { try { return javaSocket.getSendBufferSize(); } catch (SocketException e) { throw new ChannelException(e); } }
private void configureSocket(Socket socket) throws SocketException { socket.setTcpNoDelay(true); socket.setSendBufferSize(this.socketBufferSize); if(socket.getReceiveBufferSize() != this.socketBufferSize) logger.debug("Requested socket receive buffer size was " + this.socketBufferSize + " bytes but actual size is " + socket.getReceiveBufferSize() + " bytes."); if(socket.getSendBufferSize() != this.socketBufferSize) logger.debug("Requested socket send buffer size was " + this.socketBufferSize + " bytes but actual size is " + socket.getSendBufferSize() + " bytes."); }
/** * @param sock Socket. * @return Buffered stream wrapping socket stream. * @throws IOException If failed. */ final BufferedOutputStream socketStream(Socket sock) throws IOException { int bufSize = sock.getSendBufferSize(); return bufSize > 0 ? new BufferedOutputStream(sock.getOutputStream(), bufSize) : new BufferedOutputStream(sock.getOutputStream()); }
/** * See {@link Socket#getSendBufferSize()}. Calling this method does not trigger mode detection. */ @Override public synchronized int getSendBufferSize() throws SocketException { return getSocketAllowUnknownMode().getSendBufferSize(); }
@Override public int getSendBufferSize() { try { return javaSocket.getSendBufferSize(); } catch (SocketException e) { throw new ChannelException(e); } }
public ProtobufChannel(final Set<InetSocketAddress> locators, String username, String password, String keyStorePath, String trustStorePath, String protocols, String ciphers, ValueSerializer serializer) throws GeneralSecurityException, IOException { this.serializer = serializer; socket = connectToAServer(locators, username, password, keyStorePath, trustStorePath, protocols, ciphers); output = new BufferedOutputStream(socket.getOutputStream(), socket.getSendBufferSize()); }
public int getSendBufferSize() { try { return socket.getSendBufferSize(); } catch (SocketException e) { throw new ChannelException(e); } }
@Override protected void connect(SelectionKey selectionKey) throws IOException { if(!checkTimeout()) { return; } if(socketChannel.finishConnect() == false) { return; } if(logger.isDebugEnabled()) { // check buffer sizes you often don't get out what you put in! if(socketChannel.socket().getReceiveBufferSize() != this.socketBufferSize) { logger.debug("Requested socket receive buffer size was " + this.socketBufferSize + " bytes but actual size is " + socketChannel.socket().getReceiveBufferSize() + " bytes."); } if(socketChannel.socket().getSendBufferSize() != this.socketBufferSize) { logger.debug("Requested socket send buffer size was " + this.socketBufferSize + " bytes but actual size is " + socketChannel.socket().getSendBufferSize() + " bytes."); } } addClientRequest(clientRequest, timeoutMs, 0); }
private void initializeTransientFields(Socket socket, ClientProxyMembershipID pid, boolean ip, byte cc, Version vers) { this._socket = socket; this.proxyID = pid; this.connected = true; { int bufSize = 1024; try { bufSize = _socket.getSendBufferSize(); if (bufSize < 1024) { bufSize = 1024; } } catch (SocketException ignore) { } this._commBuffer = ServerConnection.allocateCommBuffer(bufSize, socket); } this._remoteHostAddress = socket.getInetAddress().getHostAddress(); this.isPrimary = ip; this.clientConflation = cc; this.clientVersion = vers; }
private void recordSocketCreation(SocketDestination dest, Socket socket) throws SocketException { int numCreated = created.incrementAndGet(); logger.debug("Created socket " + numCreated + " for " + dest.getHost() + ":" + dest.getPort() + " using protocol " + dest.getRequestFormatType().getCode()); // check buffer sizes--you often don't get out what you put in! int sendBufferSize = socket.getSendBufferSize(); int receiveBufferSize = socket.getReceiveBufferSize(); if(receiveBufferSize != this.socketBufferSize) logger.debug("Requested socket receive buffer size was " + this.socketBufferSize + " bytes but actual size is " + receiveBufferSize + " bytes."); if(sendBufferSize != this.socketBufferSize) logger.debug("Requested socket send buffer size was " + this.socketBufferSize + " bytes but actual size is " + sendBufferSize + " bytes."); }
/** * Returns the size of the send buffer on this connection's socket. */ int getSendBufferSize() { int result = this.sendBufferSize; if (result != -1) { return result; } try { result = getSocket().getSendBufferSize(); } catch (SocketException ignore) { // just return a default result = this.owner.getConduit().tcpBufferSize; } this.sendBufferSize = result; return result; }
/** * @param addr Remote address. * @param port Remote port. * @return Opened socket. * @throws IOException If failed. */ private Socket openSocket(InetAddress addr, int port) throws IOException { Socket sock = new Socket(); sock.bind(new InetSocketAddress(InetAddress.getByName("192.168.0.100"), 0)); sock.connect(new InetSocketAddress(addr, port), 1); X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() + ", sndBuf=" + sock.getSendBufferSize() + ", sndBuf=" + sock.getSendBufferSize() + ']'); return sock; } }
@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() + ']'); sockRef.set(sock); sock.getOutputStream().write( new byte[(sock.getSendBufferSize() + sock.getReceiveBufferSize()) * 2]); assert false : "Message has been written."; } catch (IOException e) { X.println("Caught expected exception: " + e); e.printStackTrace(); } finally { U.closeQuiet(sock); } return null; } },
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; } }
@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); } } },
@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() + ']'); sock.setKeepAlive(true); sock.setSoTimeout(2000); sock.setSendBufferSize(256 * 1024); X.println("Socket [timeout=" + sock.getSoTimeout() + ", linger=" + sock.getSoLinger() + ", sndBuf=" + sock.getSendBufferSize() + ", rcvBuf=" + sock.getReceiveBufferSize() + ']'); while (!done.get()) X.println("Read from socket: " + sock.getInputStream().read()); return null; } finally { U.closeQuiet(srvSock); U.closeQuiet(sock); } } },
@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; } },