Java Code Examples for java.net.Socket#getSendBufferSize()
The following examples show how to use
java.net.Socket#getSendBufferSize() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netcrusher-java File: BufferOptions.java License: Apache License 2.0 | 5 votes |
public void checkTcpSocket(Socket socket) throws SocketException { final long sizeTotal = count * size; if (sizeTotal < socket.getReceiveBufferSize()) { LOGGER.warn("Total buffer size {} is less than TCP socket SO_RCVBUF buffer size {}. Increase buffer size", sizeTotal, socket.getReceiveBufferSize()); } if (sizeTotal < socket.getSendBufferSize()) { LOGGER.warn("Total buffer size {} is less than TCP socket SO_SNDBUF buffer size {}. Increase buffer size", sizeTotal, socket.getSendBufferSize()); } }
Example 2
Source Project: nfcspy File: WiFiP2PSocket.java License: GNU General Public License v3.0 | 5 votes |
private static void tuneupSocket(Socket skt) throws SocketException { skt.setTcpNoDelay(true); skt.setTrafficClass(0x04 | 0x10); if (skt.getSendBufferSize() < WiFiP2PSocket.BUF_SIZE) skt.setSendBufferSize(WiFiP2PSocket.BUF_SIZE); if (skt.getReceiveBufferSize() < WiFiP2PSocket.BUF_SIZE) skt.setReceiveBufferSize(WiFiP2PSocket.BUF_SIZE); }
Example 3
Source Project: ignite File: TcpDiscoverySpi.java License: Apache License 2.0 | 5 votes |
/** * @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()); }
Example 4
Source Project: Doradus File: RestClient.java License: Apache License 2.0 | 5 votes |
public void connect(String host, int port) throws Exception { disconnect(); m_host = host; m_port = port; m_socket = new Socket(); if (m_socket == null) { throw new Exception("Failed to create socket"); } try { if (DISABLE_NAGLES) { m_socket.setTcpNoDelay(true); } if (USE_CUSTOM_BUFFER_SIZE) { if (m_socket.getSendBufferSize() < NET_BUFFER_SIZE) { m_socket.setSendBufferSize(NET_BUFFER_SIZE); } if (m_socket.getReceiveBufferSize() < NET_BUFFER_SIZE) { m_socket.setReceiveBufferSize(NET_BUFFER_SIZE); } } SocketAddress addr = new InetSocketAddress(m_host, m_port); m_socket.connect(addr); m_inStream = new BufferedInputStream(m_socket.getInputStream(), NET_BUFFER_SIZE); m_outStream = new BufferedOutputStream(m_socket.getOutputStream(), NET_BUFFER_SIZE); } catch(Exception ex) { disconnect(); String msg = "Failed to connect to " + m_host + ":" + m_port; throw new Exception(msg, ex); } }