0
\$\begingroup\$

I'm sending UDP packet to android over a wireless network from some other software . how can I receive that in android ? should I write a client in android to get the data?

\$\endgroup\$
1
1
\$\begingroup\$

You need to set up a DatagramSocket to receive DatagramPackets via UDP. There's an example in this SO question.

\$\endgroup\$
4
  • \$\begingroup\$ but would it get the packet from network ? it does not matter who sends these packets? \$\endgroup\$ – Aida Apr 12 '12 at 14:27
  • 1
    \$\begingroup\$ Part of setting up the DatagramSocket is defining what you are listening for... as in, the IP and PORT you expect to be getting packets to and from. \$\endgroup\$ – Myrddin Emrys Apr 12 '12 at 14:53
  • \$\begingroup\$ Generally telling people to google things in your answer body isn't a good idea. Shout at him in the question comments instead :). \$\endgroup\$ – Jonathan Dickinson Apr 12 '12 at 15:25
  • 1
    \$\begingroup\$ @matarsak how UDP works is extremely well documented on the internet - and they explain exactly how the packets arrive (answer: you get every packet that arrives on that NIC on that port - you need to decide if you want the packet). In addition as stevehb originally pointed out searching on Google got him the answer for Android straight away. You will continue to get short answers like this (or none at all) if you ask things that are so easy to find out yourself. \$\endgroup\$ – Jonathan Dickinson Apr 12 '12 at 15:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.