Multicast problem

by Thiago B. » Fri, 10 Apr 2009 01:48:53 GMT


Sponsored Links
 Hi, I'm trying to develop an application that need to send UDP
Multicast packets to the local network.
There is a few equipments that respond to this packets and send back
some informations.
I'm not worried with the server right now, because there is a server
on the same network that collect all this multicast data.
I just want to make my mobile able to send the request message to
start the process.

My client class is called MCastClient, see below:
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class MCastClient {
        private int port = 50000;
        private String addr = "239.192.1.100";
        private MulticastSocket sock = null;

        public void sendData(String data) {
                try {
                        InetAddress group = InetAddress.getByName(addr);

                        sock = new MulticastSocket(port);

                        sock.joinGroup(group);

                        DatagramPacket dataPckt = new 
DatagramPacket(data.getBytes(),
                                        data.length(), group, port);

                        sock.send(dataPckt);
                        sock.leaveGroup(group);
                        sock.close();
                } catch (Exception e) {}
        }
}

It runs perfectly on my computer as a Java Application.

On the Android Emulator i create a simple application with a button
and add a OnClickListener.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final MCastClient mcClient = new MCastClient();
    Button btn = (Button)findViewById(R.id.btn_send);

    btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mcClient.sendData("001RequestData");
        }
    });

I believe that my packet is not arriving on the local network.
I already did some test with the command "redir add udp:50000:50000"
on telnet port of the emulator, that i got from
 http://developer.android.com/guide/developing/tools/emulator.html #connecting.

There is any other command that can forward ports to the emulator?
I'm almost putting a port sniffer on my machine just to check what is
happening.

Thanks for the help, it will be very appreciated.
Thiago B.


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



Multicast problem

by David Turner » Fri, 10 Apr 2009 19:14:35 GMT


 Sorry, but the emulator currently doesn't support multicast :-(





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


Sponsored Links


Other Threads

1. Certificate webpage problem when using WebView

Hi, folks

i have a problem to show specific web page (https://
emocion.movistar.es/mstore/index.jsp) with certificate when i using
WebView..
i searched that some guy done fake X509TrustManger, but in my case no
luck.
i can only see empty screen and there is no errors on that.

Android browser can show a dialog for notice a certificate,

I am testing at 1.6 donut now

my simple code is like below

                web = (WebView) findViewById(R.id.main);
                web.getSettings().setJavaScriptEnabled(true);
                web.setWebViewClient(mWebViewClient);
                web.loadUrl("https://emocion.movistar.es/mstore/index.jsp");

There is no onReceivedSslError() callback like in BrowserActivity.java

Could you share a idea for solving this problem?

Thanks in advance...

-- 

2. How to draw my custom view when selected?

Hi,

I wrote my own custom view (derived from View). How can I handle
painting of it when it becomes focused / selected? Can I just do this:

  protected void onDraw(Canvas canvas) {
     if (isSelected()) {
         // draw my selected version
     }
     else {
         // draw normal version
     }
  }

secondly, if my view occupies a rect (after layout) that is 200 x 200
pixels in size - is there a way that I can specify which areas count
as a touch for selection? I don't want clicking in the upper-left
corner of my view to count as selecting the control, if possible. Any
way to block that?

Thanks

-- 

3. public BluetoothSocket createRfcommSocketToServiceRecord (UUID uuid)

4. Imate

5. Can not find any APN setting

6. Transparent dialog theme

7. Does styled text support html tag: <p> and <br> ?