Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Devices on all network Interface
08-10-2013, 12:59 AM
Post: #1
Get Devices on all network Interface
I started using OpenHome Libraries yesterday to build a DLNA/Upnp Media Controller. its all going well and I'm loving it so far. Thanks for all your help and support. I can now invoke play, stop, pause on my targeted DLNA Renderer successfully.

Problem statement
My PC is connected to the LAN and its also providing hotspot wifi to which all my wireless devices are connected. I can get all devices running on my PC/LAN but not the wireless interface. For example Intels source will give all devices on all interfaces with the following code
[UPnPDeviceFinder finder = new UPnPDeviceFinder();
UPnPDevices devs = finder.FindByType(type, 0);]
But in OpenHome Libraries I use

[ private void Form1_Load(object sender, EventArgs e)
{
Core.InitParams initParams = new Core.InitParams();
Core.Library lib = Core.Library.Create(initParams);
Core.SubnetList subnetList = new Core.SubnetList();
uint size = subnetList.Size();
Core.NetworkAdapter nif = subnetList.SubnetAt(0);
uint subnet = nif.Subnet();
Console.WriteLine("Using adapter: {0}", nif.Name());
subnetList.Dispose();
lib.StartCp(subnet);
iDeviceList = new List<CpDevice>();
CpDeviceList.ChangeHandler added = new CpDeviceList.ChangeHandler(DeviceAdded);
CpDeviceList.ChangeHandler removed = new CpDeviceList.ChangeHandler(DeviceRemoved);
CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("upnp.org", "RenderingControl", 1, added, removed); //urn:schemas-upnp-org:service:RenderingControl:1
}]


Printing out the Network Interface 0 gives me "Using adapter: Realtek PCIe GBE Family Controller"

Is it possible to get Devices on all active Interfaces?
Find all posts by this user
08-10-2013, 07:48 AM
Post: #2
RE: Get Devices on all network Interface
(08-10-2013 12:59 AM)Basco Wrote:  Is it possible to get Devices on all active Interfaces?

Unfortunately not. You can only run a control point stack on a single subnet so can only get devices for a single subnet.
Find all posts by this user
09-10-2013, 09:43 AM
Post: #3
RE: Get Devices on all network Interface
Thanks for the response, I got it.
In your opinion what is the best way to go around this "issue".

I may also be confusing subnets and Network Interfaces/adapters.
For now I am thinking of getting all the active subnets and the user to chosse which one to operate.
Code:
public void WriteNetworkInterfaces(XmlWriter xmlWriter)
        {
            int index = 0;
            foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (ni.OperationalStatus == OperationalStatus.Up)
                {
                    xmlWriter.WriteRaw(string.Format(@"<option value=""{0}"">{1}</option>",index, ni.Name));
                }
                index++;
            }
        }

I get an additional interface "LoopBackPseudo Interface" and will cause access violation in OHNet library
"A first chance exception of type 'System.AccessViolationException' occurred in ohNet.net.dll"
Find all posts by this user
09-10-2013, 10:44 AM
Post: #4
RE: Get Devices on all network Interface
(09-10-2013 09:43 AM)Basco Wrote:  Thanks for the response, I got it.
In your opinion what is the best way to go around this "issue".

I may also be confusing subnets and Network Interfaces/adapters.
For now I am thinking of getting all the active subnets and the user to chosse which one to operate.

I get an additional interface "LoopBackPseudo Interface" and will cause access violation in OHNet library
"A first chance exception of type 'System.AccessViolationException' occurred in ohNet.net.dll"

Having the user select a subnet would be good. That's exactly what many other ohNet clients do.

The crash when you select loopback is a bug. I've reported this internally but it might be a while before we get a chance to look at it.

You can avoid the crash (and various potential sources of user confusion) by using ohNet's Core.SubnetList class to enumerate the available network adapters.
Find all posts by this user


Forum Jump: