I'm using this code on real device. I know there is someone wants to port UPnP stack to Android. But I don't know any DLNA application on Android from official or other open source project. Could you tell me the application name or its info? Thank you very much.
On May 19, 3:54 pm, Daniel Janev <[email protected]> wrote: > Hi, > > You use the SDK and the emulator or you are trying this code on real > device? > > As far as I know there is DLNA application for Android, which works on > the phone using the WiFi connection. > > > > > > Whinowrote: > > The following is the listen function I used to receive multicast > > packets. > > "socket.receive" can not receive packets from remote peer, but it can > > receive packets sent from local. > > > public static void listen() throws IOException { > > Runnable r = new Runnable() { > > public void run() { > > > while (true) { > > try { > > MulticastSocket socket = new MulticastSocket > > (1900); > > Log.v(TAG, "Setting multicast network > > interface: " + ni); > > socket.setNetworkInterface(ni); > > > socket.setTimeToLive(4); > > socket.setReuseAddress(true); > > socket.joinGroup(getMulticastAddress()); > > while(true) > > { > > byte[] buf = new byte[1024]; > > DatagramPacket packet_r = new > > DatagramPacket(buf, buf.length); > > socket.receive(packet_r); > > String s = new String(packet_r.getData()); > > > Log.v(TAG, "Receiving a Multicast from [" > > + packet_r.getAddress().getHostAddress() + ":" + packet_r.getPort() + > > "]"); > > Log.v(TAG, "Data: " + s); > > > CharSequence data = packet_r.getAddress > > ().getHostAddress() + ":" + packet_r.getPort(); > > Toast.makeText(view, data, > > Toast.LENGTH_SHORT).show(); > > } > > } catch (IOException e) { > > Log.v(TAG, "UPNP network exception", e); > > try { > > Thread.sleep(1000); > > } catch (InterruptedException e1) {} > > } > > } > > > }}; > > sListener = new Thread(r); > > sListener.start(); > > } > > -- > > Best Regards, > Daniel > --------------------------------------------------------------- > Daniel Janev · Department Manager/Core Platform and Smart Home > ProSyst Software GmbH > 1606 Sofia, Bulgaria · Vladajska Str. 48 > Tel. +359 (0)2 952 35 81/109 · Fax +359 (0)2 953 26 17 > Mobile Phone +359 (0)888 678 670http://www.prosyst.com· [email protected] > --------------------------------------------------------------- > stay in touch with your product. > ---------------------------------------------------------------- Hide quoted > text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

