0
我在我的android模拟器上运行tcpdump,并且由于tcpdump在后台运行,因此缓冲区中没有任何数据,因此应用程序停留在此位置。 这里是代码的一部分:输出缓冲区为空,直到tcpdump被杀死
else if (tcpdumpButton.isChecked())
{
try
{
Process process1 = Runtime.getRuntime().exec("tcpdump");
DataOutputStream os = new DataOutputStream(process1.getOutputStream());
BufferedReader osRes = new BufferedReader(new InputStreamReader(process1.getInputStream()));
//ByteArrayInputStream osRes = (ByteArrayInputStream) process1.getInputStream();
// os.writeBytes("tcpdump -l port 80");
os.flush();
StringBuffer output = new StringBuffer();
try
{
while ((osRes.readLine()) != null)
{
output.append(osRes.readLine());
output.append("\n");
}
}
catch (Exception e)
{
throw e;
}
process1.waitFor();
tv.setText(output);
setContentView(tv);
}
catch (Exception e)
{
throw e;
}
任何帮助吗?
您正在开始'tcpdump'子进程。什么使它终止? – erickson 2010-09-08 06:51:54
我不希望它终止,因为我想捕获所有的数据包 – Jony 2010-09-08 06:57:13