我想在我的android应用程序中实现一个功能来打开/关闭我的av接收器。因此,我创建了一个套接字,并通过Telnet向接收方发送命令,但什么也没有发生。成功地创建了套接字!
我的av接收器是Denonx-2000,根据官方协议,我必须发送PWSTANDBY命令。
public void turnOff(View v){
Runnable r = new Runnable() {
@Override
public void run() {
Socket s = null;
PrintWriter out = null;
BufferedReader in= null;
try{
InetAddress ia = InetAddress.getByName("192.168.100.228");
s= new Socket(ia, 23);
out = new PrintWriter(s.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
} catch(IOException e){
}
Log.v("output","send standby");
out.println("PWSTANDBY");
out.flush();
try {
if(in.ready())
Log.v("input", in.readLine());
} catch (IOException e) {
e.printStackTrace();
}
out.close();
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
s.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
Thread t = new Thread(r);
t.start();
}发布于 2014-06-29 13:54:10
好的,我自己找到了一个解决方案,我改变了路线
out.println("PWSTANDBY");至
out.print("PWSTANDBY\r");而且起作用了。
https://stackoverflow.com/questions/24430190
复制相似问题