android - 为什么我尝试发送数据时出现“setCommandByIoctl failed”?
问题描述
我正在编写代码以将数据从客户端发送到服务器。但是,当我尝试向服务器发送数据时,遇到以下错误。我确信连接已经建立。我已经在 Internet 上搜索了有关该错误的信息。但是,以前没有遇到过这样的错误。
这是错误的logcat:
W/e.magickeyboard: type=1400 audit(0.0:52635): avc: denied { ioctl } for pid=18094 path="/proc/18094/rtg" dev="proc" ino=1605802 ioctlcmd=0xab20 scontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tclass=file permissive=0
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
V/AudioManager: querySoundEffectsEnabled...
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
W/e.magickeyboard: type=1400 audit(0.0:52636): avc: denied { ioctl } for pid=18094 path="/proc/18094/rtg" dev="proc" ino=1605802 ioctlcmd=0xab20 scontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tclass=file permissive=0
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
W/e.magickeyboard: type=1400 audit(0.0:52637): avc: denied { ioctl } for pid=18094 path="/proc/18094/rtg" dev="proc" ino=1605802 ioctlcmd=0xab20 scontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tclass=file permissive=0
W/e.magickeyboard: type=1400 audit(0.0:52638): avc: denied { ioctl } for pid=18094 path="/proc/18094/rtg" dev="proc" ino=1605802 ioctlcmd=0xab20 scontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tclass=file permissive=0
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
W/e.magickeyboard: type=1400 audit(0.0:52639): avc: denied { ioctl } for pid=18094 path="/proc/18094/rtg" dev="proc" ino=1605802 ioctlcmd=0xab20 scontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c182,c256,c512,c768 tclass=file permissive=0
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
D/RtgSchedIpcFile: setCommandByIoctl failed ret:-1, cmdid:32, errno:13
我不知道这是什么意思。
这是我构建套接字以连接到服务器的客户端代码:
btnConnect = (Button) findViewById(R.id.connect);
btnConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mThreadPool.execute(new Runnable() {
@Override
public void run() {
try {
socket=new Socket("192.168.101.2",9102);
System.out.println(socket.isConnected());
boolean m=socket.isConnected();
if(m) {
Log.d("Connect","True");
}
if(!m){
Log.d("Connect","Connect false");
}
} catch (IOException e) {
e.printStackTrace();
Log.d("Connect",Log.getStackTraceString(e));
}
catch(NullPointerException e){
Log.d("Connect",Log.getStackTraceString(e));
}
catch(NetworkOnMainThreadException e){
Log.d("Connect",Log.getStackTraceString(e));
}
}
});
}
});
下面是我将数据传输到服务器的客户端代码:
btnSend = (Button) findViewById(R.id.send);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mThreadPool.execute(new Runnable() {
@Override
public void run() {
try {
outputStream = socket.getOutputStream();
outputStream.write(floatToByte(a));
outputStream.flush();
} catch (IOException e) {
Log.d("send",Log.getStackTraceString(e));
}
catch(NullPointerException e)
{
Log.d("send",Log.getStackTraceString(e));
}
}
这是我的服务器的代码:
try {
ServerSocket serverSocket=new ServerSocket(9102);
Socket socket=serverSocket.accept();
InputStream is=socket.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is));
String info=null;
while(!((info=br.readLine())==null)){
System.out.println("This is the server:"+info);
}
OutputStream os=socket.getOutputStream();
PrintWriter pw=new PrintWriter(os);
String reply="welcome";
pw.write(reply);
pw.flush();
pw.close();
br.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
解决方案
推荐阅读
- python - 列出给定数量python需要哪些硬币
- node.js - 不确定是否正确安装 Angular CLI
- java - 为多态实体编写 Spring 数据存储库 - InheritanceType.SINGLE_TABLE
- python - 带有单词建议 Python 的语法/拼写检查
- facebook-graph-api - Facebook API - 发布到页面
- cron - Airflow schedular 不会在特定 schedule_interval 配置中选择 DAG(0 8 * * 5)
- asp.net - 激活 ILogManager 时出错:没有可用的匹配绑定,并且类型不可自绑定
- grails - 将 obj 和数量列表放入 commnad obj 中
- git - 使用 Git 过滤分支时添加注释以提交
- unity3d - 通过透视相机投影正交矩阵