I'm facing UDP packet loss problem based on Android devices. I have two devices. Following code works correctly on one device. The other device lost many packages. I have already read solution of similar problem. In this solution, setting the datagram socket size to 64k is suggested. But I couldn't set it.
How can I change datagram buffer size?
My code:
DatagramSocket udpSocket = null;
try {
udpSocket = new DatagramSocket(5004);
udpSocket.setReceiveBufferSize(64*1024);
Log.d("UDPSocket", "Buffer Size : " + udpSocket.getReceiveBufferSize());
} catch (SocketException e1) {
e1.printStackTrace();
}
Log:
05-14 10:34:05.960: D/UDPSocket(28021): Buffer Size : 112640