Socket running but not receiving values over the port
<p>I have an <code>OpenPicus Flypport</code> Device which sends <code>JSON</code> String when queried with proper string over Port No. 50000 (<strong>UDP</strong>).</p>

<p><em>Well thats not mandatory just for an information</em></p>

<p>What I am doing is I query the device with proper json, and the device replies back. But my Android code do not receives the reply. I have taken all the required <code>WIFIManager Code</code>, and <code>Wifi Permissions</code>.</p>

<p>To check weather the Android is broadcasting or not, I wrote a java program running on my laptop. There I found that both the Android and Flyport Device are communicating.</p>

<p>I have written following code:</p>

<p><strong>SENDING FROM ANDROID</strong></p>

<pre><code>        System.out.println("Sending Flyport");
        FlyportDriver flyDriver = new FlyportDriver();
        sendMulticastFlyport = new Thread(new FlyportSender(set.getFlyportIP() , flyDriver.getDeviceDiscovery()));
        //flyport.getDeviceDiscovery is JSON String. Sending is fine. No problem
        sendMulticastFlyport.start();
        System.out.println("Flyport Send: "+flyDriver.getDeviceDiscovery());
        deviceStartCounter++;
</code></pre>

<p><strong>RECEIVING ON ANDROID</strong></p>

<pre><code>private class DeviceSearcher extends AsyncTask&lt;Void, DeviceInformation ,Void&gt;
{
    @Override
    protected void onPreExecute()
    {
        super.onPreExecute();
        //TableLayout deviceTable = (TableLayout) findViewById(951357);
        TableRow tr = new TableRow(getApplicationContext());
        LayoutParams layout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        tr.setLayoutParams(layout);
        TextView tv = new TextView(getApplicationContext());
        tv.setText("Searching...");
        tv.setLayoutParams(layoutParam);
        tv.setTextColor(Color.WHITE);
        tv.setVisibility(View.VISIBLE);
        tr.addView(tv);
        deviceTable.addView(tr);
    }
    @Override
    protected Void doInBackground(Void... arg0)
    {
            new Thread()
            {
                public void run()
                {
                    MulticastSocket socketFlyport=null;
                    try
                    {
                        socketFlyport = new MulticastSocket(50000);
                        socketFlyport.setSoTimeout(1*20*1000);
                        byte[] inBufFlyport = new byte[1024];
                        DatagramPacket inPacketFlyport = new DatagramPacket(inBufFlyport, inBufFlyport.length);

                        while(true)
                        {
                            System.out.println("Listening..."); //Printing
                            socketFlyport.receive(inPacketFlyport); //not receiving

                            String msg = new String(inBufFlyport, 0, inPacketFlyport.getLength());
                            Log.v("Received:","Received Flyport From :" + inPacketFlyport.getAddress() + " Msg : " + msg);
                            String IP = inPacketFlyport.getAddress().toString();
                            System.out.println(Utils.getIPAddress(true));
                            try
                            {
                                System.out.println("Received");
                                DeviceInformation device = new DeviceInformation(3, IP.substring(1), msg, getApplicationContext());
                                publishProgress(device);
                            }
                            catch(Exception e)
                            {
                                System.out.println(e.toString());
                            }
                            Log.v("Received:","Received Flyport From :" + inPacketFlyport.getAddress() + " Msg : " + msg);
                            System.out.println();
                            Thread.sleep(2500);
                        }
                    }
                    catch(Exception e)
                    {
                        Log.v("Exception:","During Receiving Flyport: "+e.toString());
                        publishProgress((DeviceInformation)null);
                    }
                    finally
                    {
                        socketFlyport.close();
                    }
                }
            }.start();
        return null;
    }
</code></pre>

<p>If you will see then I have printed some variables.</p>
