title: Android DatagramSocket receive buffer size
body: <p>I am trying to set/increase the receive buffer size of a datagram socket. I would like to do this since I am experiencing some random packet loss when sending data between a PC and the Android device which lie on the same local network and I would like to test if increasing the buffer size would have any effect in reducing this UDP packet loss. I am trying to set the buffer size using the below code.</p>
  
  <pre><code>DatagramSocket socket = new DatagramSocket();
  socket.setReceiveBufferSize(655360);
  </code></pre>
  
  <p>and then later on (before I start reading from the socket) I check the receive buffer size as follows:</p>
  
  <pre><code>Log.i(TAG, "Size: " + socket.getReceiveBufferSize());
  </code></pre>
  
  <p>However, the log message always displays a buffer size of 163840. 
  What is the problem with this code? Should I set the receive buffer size in another way.</p>
  
  <p>Thanks</p>