在java项目里,socket连接后加入如下代码:
System.out.println("rsize: "+socket.getReceiveBufferSize());
socket.setReceiveBufferSize(120);
System.out.println("rsize: "+socket.getReceiveBufferSize());
会得到结果:
rsize: 65536
rsize: 120
但如果在安卓里加入类似代码:
Log.e("xjfjian", "rsize: "+mSocket.getReceiveBufferSize());
mSocket.setReceiveBufferSize(120);
Log.e("xjfjian", "rsize: "+mSocket.getReceiveBufferSize());
结果不确定:
安卓9,as自带模拟器:
xjfjian: rsize: 1059840
xjfjian: rsize: 2304
安卓5,夜神模拟器:
xjfjian: rsize: 1048576
xjfjian: rsize: 2240
想了解一下原因,是安卓本身的问题还是模拟器的问题?以及有没有办法规避这个问题?
理论+实践,系统且深入掌握Socket核心技术,从容应对各种Socket应用场景的不二之选
了解课程