我将我的电脑屏幕截图发送到udp上的android选项卡。当图像数据的大小增加时,传输停止。正在发送10 kb的图像,当图像尺寸变为12kb时,不接收图像,如果图像尺寸小于初始接收尺寸,则在标签中接收图像。这背后的原因是什么?我接收数据报包的代码是
private class Udpreceiver implements Runnable {
String path = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
+ File.separator + "Simple";
File directory = new File(path);
byte[] incommmingData = new byte[65 * 1024];
DatagramPacket p = new DatagramPacket(incommmingData,
incommmingData.length);
int file_size;
public void run() {
try {
while (true) {
datagaramSoc = new DatagramSocket(1546);
FileOutputStream outStream = null;
file_Num = file_Num + 1;
datagaramSoc.receive(p);
file_size = Integer.parseInt(new String(p.getData())
.substring(2).substring(0, 5));
if (!directory.isDirectory()) {
directory.mkdir();
}
imagePath = new File(path + "/" + file_Num
+ "SimpleImage.jpg");
outStream = new FileOutputStream(imagePath);
BufferedOutputStream bos = new BufferedOutputStream(
outStream);
bos.write(p.getData(), FILE_START, file_size);
bos.flush();
bos.close();
outStream.flush();
outStream.close();
p.setLength(incommmingData.length);
runThread(file_Num);
datagaramSoc.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (datagaramSoc != null)
datagaramSoc.close();
}
};
}
请帮我解决这个问题