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.
DatagramSocket socket = new DatagramSocket();
socket.setReceiveBufferSize(655360);
and then later on (before I start reading from the socket) I check the receive buffer size as follows:
Log.i(TAG, "Size: " + socket.getReceiveBufferSize());
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.
Thanks