Routing UDP data to the emulator

by Tim » Fri, 27 Mar 2009 01:11:59 GMT


Sponsored Links
 I've been scouring the forums and found similar issues like this, but
the solutions seems not to be working.

What we're doing is trying to receive data from an external server via
UDP. At the moment, doing a tcpdump on linux provides information that
yes, there is data coming into my computer. From here, however, things
become murky.

I have tried the following two tactics:

telnet localhost 5554

where 5000 is the port on my computer that is receiving data and 5000
is the port where Android is listening to. This achieves nothing.

The other tactic is the adb forward, which has the same results.

The UDP Server code is as follows:

public class Server extends Thread {
        private InetAddress serverAddr;
        private DatagramSocket socket;

        private static int port = 5000;
        private static final String tag = "UDP Server";

        public Server() {
                try {
                        this.serverAddr = InetAddress.getByName("10.0.2.15");
                        this.socket = new DatagramSocket(port, this.serverAddr);
                        Log.d(tag, "listening port 5000");
                } catch (Exception e) {
                        Log.d(tag, "Failed accessing server address and 
socket");
                }
        }

        public void start() {
                super.start();
        }

        public void run() {
                Looper.prepare();
                while(true) {
                        try {
                                byte[] buf = new byte[43];
                                /* Prepare a UDP-Packet that can
                                 * contain the data we want to receive */
                                DatagramPacket packet = new DatagramPacket(buf, 
buf.length);

                                this.socket.receive(packet);  // Receive the 
UDP-Packet
                                Log.d(tag, "Received: '" + new 
String(packet.getData()) + "'");
                        } catch (IOException e) {
                                Log.e(tag, "Error", e);
                        }
                }
        }
}

What this should do is listen to Android's network/ethernet interface
and output the recieved data (if there is any). What I get is nothing.
Android does not say that there is an error in Logcat or that anything
is received. This seems to tell me that the information is not being
redirected properly to the emulator.

Any thoughts on getting this redirection business settled?

--~--~---------~--~----~------------~-------~--~----~



Routing UDP data to the emulator

by David Turner » Fri, 27 Mar 2009 03:24:26 GMT


 Did you try listening to 0.0.0.0 and/or 10.0.2.2 ?





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Routing UDP data to the emulator

by Tim » Sat, 28 Mar 2009 23:33:16 GMT


 I did a check using netstat and found that when I routed the udp
packet using
telnet localhost 5554

that the port that is listening to is
0.0.0.0:5000

which does make things a bit better in terms of where its going to,
but the emulator
can't seem to make that last connection to it.

I'm going to try writing some code that will forward that data to
0.0.0.0:5000 and see
how the emulator reacts to that.

Any other solutions would be welcomed.
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Using google Maps

Anyone has some sample code which i can look at for me to start off
interfacing with Maps. In my app i will need to get from place A to B
showing me with the use of an arrow the direction i should take. (i.e
similar to a GPS system). I am very new to android :(.
Thanks to all that can help me.

--~--~---------~--~----~------------~-------~--~----~

2. Maximum size of database

I am considering two options of creating database and interested in
knowing the maximum size that can be given to a database.
1. I see that SQLlite allows us to set the maximum size allowable for
the database. Can this be set to the maximum available on the
device  ?
2. What would be the maximum allowable size of database if I use
content provider ?

In other words, What is the max size a db can grow on thee Android
device, can it cover the total available memory space of the app, or
it has its own limit?

Thanks for ur time.
--~--~---------~--~----~------------~-------~--~----~

3. is the order value of Menu.CATEGORY_SECONDARY a property of the menu item or the group?

4. Developers Count on Android v's iPhone?

5. Starting an instrumentation with an intent

6. How & When we use "KeyguardLock" or "KeyguardManager"

7. Activities Refactoring