AndroidデバイスはUSB経由でコンピュータに接続しています。 TCPポート転送をadb forward tcp:<port> tcp:<port>
で有効にして、ソケットと正常に通信しましたが、私はUDPで同じことをする方法がわかりません。PCとAndroidアプリの間でUSB通信のUDP転送を有効にする方法
EDIT v1の:私はエミュレータ上で自分のアプリケーションを立ち上げ、telnet localhost 5554
を入力し、redir add udp:<port>:<port>
、それ が働いていた、私はls
をしようとすると、それが働いているので、私の関数executeCMDがfunctionnalです。
一部のWebサイトには、このredir add udp:<port>:<port>
ようredir
を使用するように言ったが、私はそうするとき、私はエラーを取得:
usage:
redir --lport=<n> --cport=<n> [options]
redir --inetd --cport=<n>
Options are:-
--lport=<n> port to listen on
--laddr=IP address of interface to listen on
--cport=<n> port to connect to
--caddr=<host> remote host to connect to
--inetd run from inetd
--debug output debugging info
--timeout=<n> set timeout to n seconds
--syslog log messages to syslog
--name=<str> tag syslog messages with 'str'
--connect=<str> CONNECT string passed to proxy server
--bind_addr=IP bind() outgoing IP to given addr
--ftp=<type> redirect ftp connections
where type is either port, pasv, both
--transproxy run in linux's transparent proxy mode
--bufsize=<octets> size of the buffer
--max_bandwidth=<bit-per-sec> limit the bandwidth
--random_wait=<millisec> wait before each packet
--wait_in_out=<flag> 1 wait for in, 2 out, 3 in&out
Version 2.2.1.
は、それから私は、私は、このメソッドを作成したので、このコマンドは、Androidデバイス上で起動する必要があります考えた:
public String executeCMD(String cmd){
StringBuffer output = new StringBuffer();
try{
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
while ((read = reader.read(buffer)) > 0) output.append(buffer, 0, read);
reader.close();
process.waitFor();
} catch(IOException e){ e.printStackTrace();
} catch(InterruptedException e){ e.printStackTrace(); }
return output.toString();
}
そして、私はそのように呼ばれる:
executeCMD("redir add udp:" + UDP_PORT + ":" + UDP_PORT)
出力がなく、UDPサーバーは、UDPクライアントと通信できません。
私は少し失われています...私は検索を続けますが、あなたが私を助けることができます。先に行く。
ありがとうございました。だから、最終的には