Java Code Examples for java.net.Socket#getReceiveBufferSize()
The following examples show how to use
java.net.Socket#getReceiveBufferSize() .
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: Tomcat8-Source-Read File: ObjectReader.java License: MIT License | 5 votes |
/** * Creates an <code>ObjectReader</code> for a TCP socket * @param socket Socket */ public ObjectReader(Socket socket) { try{ this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true); }catch ( IOException x ) { //unable to get buffer size log.warn(sm.getString("objectReader.retrieveFailed.socketReceiverBufferSize")); this.buffer = new XByteBuffer(43800,true); } }
Example 2
Source Project: Tomcat7.0.67 File: ObjectReader.java License: Apache License 2.0 | 5 votes |
/** * Creates an <code>ObjectReader</code> for a TCP socket * @param socket Socket */ public ObjectReader(Socket socket) { try{ this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true); }catch ( IOException x ) { //unable to get buffer size log.warn("Unable to retrieve the socket receiver buffer size, setting to default 43800 bytes."); this.buffer = new XByteBuffer(43800,true); } }
Example 3
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 4
Source Project: tomcatsrc File: ObjectReader.java License: Apache License 2.0 | 5 votes |
/** * Creates an <code>ObjectReader</code> for a TCP socket * @param socket Socket */ public ObjectReader(Socket socket) { try{ this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true); }catch ( IOException x ) { //unable to get buffer size log.warn("Unable to retrieve the socket receiver buffer size, setting to default 43800 bytes."); this.buffer = new XByteBuffer(43800,true); } }
Example 5
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 6
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); } }