Regarding Multicast issue on WifiDirect Interface

1,042 views
Skip to first unread message

PraveenThota

unread,
Jan 18, 2012, 2:46:31 AM1/18/12
to android-platform
Hi All,
I am trying to send the multicast packet on the Wifi Direct interface
on
ICS Platform.
The multicast socket joingroup api returns the ENODEV Exception, but
the
same code works perfectly fine on the Wifi Interface.
I am able to successfully send and receive multicast packets over the
Wifi
Interface.
The issue is only with the WIFI DIRECT Interface.
Please let me know if any one has any solution.


Thanks & Regards,
Praveen Thota.


---------------------------------------------------------------------------­---------------------------------------------------------------------------­-----


01-11 16:13:16.859: W/System.err(7255): java.net.SocketException:
setsockopt failed: *ENODEV (No such device)*


01-11 16:13:16.859: W/System.err(7255): at
libcore.io.IoBridge.setSocketOption(IoBridge.java:303)


01-11 16:13:16.859: W/System.err(7255): at
java.net.PlainDatagramSocketImpl.setOption(PlainDatagramSocketImpl.java:
186­)


01-11 16:13:16.859: W/System.err(7255): at
java.net.PlainDatagramSocketImpl.join(PlainDatagramSocketImpl.java:
126)


01-11 16:13:16.859: W/System.err(7255): at
java.net.MulticastSocket.joinGroup(MulticastSocket.java:149

Anup Kulkarni

unread,
Mar 30, 2013, 12:57:20 PM3/30/13
to android-...@googlegroups.com

P2P interface usually gets created dynamically after group owner negotiation. Please make sure that the interface exist before you run your code.

Otherwise I dont see any reason for multicast to fail on p2p interface. It is just another network interface (AP/sta)

Thanks
Anup

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

chand...@gmail.com

unread,
Jul 11, 2013, 1:05:08 AM7/11/13
to android-...@googlegroups.com

Hi PraveenThota i am working on Multicast on android 4.0.1 ICS on Micromax Tablet alpha p250. But i am not able to receive the multicast packet.I am trying to receive through Wifi Interface. via an AP.  I am getting the error "setsockopt failed ENODEV". Below is my code in eclipse.Plz suggest any soln because u are telling that u are able to receive multicast. Im think u can help me


package com.example.cdttiming;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;

import android.R.integer;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.view.Menu;
import android.widget.EditText;


public class MainActivity extends Activity
{

    @Override
     
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText Seconds;
        Seconds =(EditText)findViewById(R.id.Seconds);
       
        WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
        WifiManager.MulticastLock multicastLock = wm.createMulticastLock("mydebuginfo");
        multicastLock.setReferenceCounted(true);       
        multicastLock.acquire();
         
            InetAddress ia = null;
            byte[] buffer = new byte[65535];
            MulticastSocket ms = null;
            int port = 4321;
            try
            {
            ia = InetAddress.getByName("226.1.1.1");
            DatagramPacket dp = new DatagramPacket(buffer, buffer.length,ia,port);
            ms = new MulticastSocket(port);
            ms.setReuseAddress(true);
            ms.joinGroup(ia);
               
               
              // while (true)
               for(int i=0;i<10;i++)
                {
                    ms.receive(dp);
                    String s = new String(dp.getData(),0,dp.getLength());
                    Seconds.setText(s);
                }
               
              

            }
            catch (UnknownHostException e)
            {
                Seconds.setText(e.getMessage());
                 
            }
            catch (IOException e)
            {
                Seconds.setText(e.getMessage());
            }
           
          

    }

    @Override
     public boolean onCreateOptionsMenu(Menu menu)
    {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }   

}


The  Manifest File is like this

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.cdttiming"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    
    

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.cdttiming.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Reply all
Reply to author
Forward
0 new messages