Sample Header Ad - 728x90

How can I activate UDP forwarding for USB communication between a PC and an Android app

5 votes
1 answer
10062 views
I have an *real* Android device connected to a computer via USB. I managed to activate **TCP** port forwarding with adb forward tcp: tcp: and successfully communicate with sockets but I don't know how to do the same for **UDP**. > **EDIT** : I launched my application on the emulator and typed telnet localhost 5554 and redir add udp:: and it > worked, my function executeCMD is functionnal because when I try ls > it's working. Some websites said to use redir like this redir add udp:: but when I do so I obtain an error : usage: redir --lport= --cport= [options] redir --inetd --cport= Options are:- --lport= port to listen on --laddr=IP address of interface to listen on --cport= port to connect to --caddr= remote host to connect to --inetd run from inetd --debug output debugging info --timeout= set timeout to n seconds --syslog log messages to syslog --name= tag syslog messages with 'str' --connect= CONNECT string passed to proxy server --bind_addr=IP bind() outgoing IP to given addr --ftp= redirect ftp connections where type is either port, pasv, both --transproxy run in linux's transparent proxy mode --bufsize= size of the buffer --max_bandwidth= limit the bandwidth --random_wait= wait before each packet --wait_in_out= 1 wait for in, 2 out, 3 in&out Version 2.2.1. Then I thought this command should be launch on the Android device so I created this method : 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; 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(); } And when I called it like that : executeCMD("redir add udp:" + UDP_PORT + ":" + UDP_PORT) I get no output and the **UDP** server on the Android app can't communicate with the **UDP** client. So I'm a bit lost... I'll continue searching but If you can help me; go ahead. Thanks.
Asked by geauser (151 rep)
Apr 5, 2016, 04:39 PM
Last activity: Oct 14, 2023, 12:49 PM