locked
how to set network in Metro style apps?

    Question

  • I want to access the network settings including IP address, DNS, gateway etc. in metro style app. However, some APIs like GetAdaptersInfo in iphlpapi.dll can not be called, because it is not in the Application Family region.

    How can I set or get network settings in Metro style applicaton? Which WinRT classes or new Win32 APIs can be used? Thanks!

    Monday, February 20, 2012 2:19 AM

Answers

All replies

  • For network setting, user should set it via the Windows Connection Management UI, not by an application.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    Monday, February 20, 2012 6:15 AM
  • And what about GETting ? I have the same problem and I currently see no way to resolve it. The only network adapter info available is in NetworkAdapter class and it's completely useless: no IP addresses, no MAC addresses, no nothing...
    Friday, March 2, 2012 12:04 PM
  • Hi u2mithrandir, Shephph,

    Could you please tell us what your apps are trying to do? That may help us to picking some valuable networking APIs.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 5, 2012 6:17 PM
  • Currently I need to implement SNMP agent discovery via broadcast, in order to do that I need to send SNMP PDU on all available network interfaces. This is required because in case of multihomed computer I would have to get SNMP agents from all networks which the computer is connected to. So, the steps are:

    1. Enumerate all interfaces

    2. Create a socket for each interface and bind it to the interface

    3. Send the PDU

    4. Wait for responses

    Actually, I've found an API for that, it's called DatagramSocket::GetEndpointPairsAsync, though I don't understand why it's a static member of an DatagramSocket class, DNS resolution and interface enumeration has nothing to do with UDP, it has to be a separate class (or even classes), something like Resolver and NetworkInterface, I would then call Resolver::resolve(...) and NetworkInterface::getInterfaces(...) or something like that. BTW, DatagramSocket::GetEndpointPairsAsync API seems to be buggy, I've already asked a question about that here: http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/da7ecc56-080a-499d-9e4d-2bd8b883e37d

    I personally think that there's no need to reinvent the wheel here, there are plenty of object oriented APIs for the things we discuss, see Poco, Qt, Java or C#. 

    P.S: I'm actually have a feeling that you're going to suggest me DatagramSocket::BindServiceAsync API for my task. I've tried to use that API in the developer preview and I don't know if it changed since, but it did very strange things in the developer preview. It "bound" the socket to SEVERAL network addresses, i.e. it was using the service name that I passed to it and "bound" the socket to IPv4 and IPv6 addresses on "0:0:0:0" and "::". I'm writing "bound" in quotes because this is not binding, a socket cannot be bound to several addresses. What'll happen to such a "socket" when I send data to it ? It'll send it on all interfaces ? And what about receiving, setting socket options, etc. ? This is completely counterintuitive and error prone and this is not how sockets should work, I personally think that such APIs should go, like I said before, no need to reinvent the wheel, everything is invented already...

    Monday, March 5, 2012 8:00 PM
  • ... It "bound" the socket to SEVERAL network addresses, i.e. it was using the service name that I passed to it and "bound" the socket to IPv4 and IPv6 addresses on "0:0:0:0" and "::". I'm writing "bound" in quotes because this is not binding, a socket cannot be bound to several addresses. What'll happen to such a "socket" when I send data to it ? It'll send it on all interfaces ? And what about receiving, setting socket options, etc. ? This is completely counterintuitive and error prone and this is not how sockets should work, I personally think that such APIs should go, like I said before, no need to reinvent the wheel, everything is invented already...

    The StreamSocket sample code demonstrates a StreamSocket class instantiated on the localhost (0.0.0.0). I too am looking for not only a way, but a simplified way, to do a device to machine connect across the MetroUI and the Desktop platforms. David Lamb's posting (Dev Center - Metro style apps > Windows Metro style apps Forums > Building Metro style apps with C++ > Using WinRT from Desktop applications) prophecies that WinRT will eventually work its way into the Desktop and the it will simplify async IPC. He says to look at the description of the methods as to whether they are MetroUI, Desktop or both. The StreamSocket class is supposed to work in both environments. Its ConnectAsync method can take an EndpointPair. EndpointPair has a property, RemoteHostName, which has a get and a set. Here is RemoteHostName's description: A string that contains an IPv4 or an IPv6 network address of the remote host. An IPv4 address string is in dotted-decimal notation ("192.168.1.111", for example). An IPv6 address is in hexadecimal notation ("21DA:00D3:0010:2F3B:02AA:00FF:FE28:9C5A", for example).

    Unless there is a mistake somewhere, then I believe we will eventually see simplified async IP endpoint to IP endpoint access across both environments. If I were a developer at MS, I would settle for nothing less. My advice? Hold tight a few more months until the dust settles on these methods in both environments. The appearance of C++ samples will mark the time when we can use them without fear of disruptive change by MS (to our apps) in the future and be able to take advantage of the new and improved simplified async capabilities.


    RT




    Tuesday, April 10, 2012 2:03 PM
  • we need this information as well. We work with SIP and XMPP. These protocols require SRV DNS lookups. These DNS lookups are not supported by the networking stack of WINRT, so we want to integrate our own managed DNS resolver using UDP sockets. But we have to figure our the DNS server of the machine in order to send the DNS queries.

    Thanks,
    Alex


    Alexander Gnauck, AG-Software

    Wednesday, May 23, 2012 12:47 PM
  • I want to access the network settings including IP address, DNS, gateway etc. in metro style app. However, some APIs like GetAdaptersInfo in iphlpapi.dll can not be called, because it is not in the Application Family region.

    I can address MetroUI to Desktop IP addressing functionality using StreamSocket and BindEndpointAsync. See my thread: StreamSocket Sample with Fixed IP address/port number endpoint. The new and simplified async functionality works great with no limitations.


    RT

    Wednesday, May 23, 2012 2:53 PM
  • I want to access the network settings including IP address, DNS, gateway etc. in metro style app. However, some APIs like GetAdaptersInfo in iphlpapi.dll can not be called, because it is not in the Application Family region.

    I can address MetroUI to Desktop IP addressing functionality using StreamSocket and BindEndpointAsync. See my thread: StreamSocket Sample with Fixed IP address/port number endpoint. The new and simplified async functionality works great with no limitations.


    RT

    RT, This is not what we are looking for. We want to get info about the network interfaces of the machine. The IP-Address, DNS server, gateway and other stuff assigned to each of this interfaces.

    In the full .NEt Framework you can do this with teh classes in the System.Net.NetworkInformation namespace.http://msdn.microsoft.com/de-de/library/system.net.networkinformation.aspx

    In WinRT/Metro there is nothing which is a blocker for many networking apps.

    Alex


    Alexander Gnauck, AG-Software

    Wednesday, May 23, 2012 4:35 PM
  • Same boat here, looking to get network interface details. Any further movement, workarounds? 
    Thursday, November 22, 2012 7:28 AM