0

I'm wondering how I can use the mobile broadband connection of a device from my application, written as a UWP app. I am using the following code that allows me to connect to the desired device via WiFi, but it isn't working via the mobile broadband connection. The device contains a Machine-To-Machine SIM card that links to our company network.

    private async void button1_Click(object sender, RoutedEventArgs e) {
        var sSocket = new Windows.Networking.Sockets.StreamSocket();
        try {
            var res = sSocket.ConnectAsync(new Windows.Networking.HostName("10.203.120.71"), "80");
            await res.AsTask();
            await NotifyUser(res.Status.ToString());
        }
        catch (Exception) {
            await NotifyUser("Failed", "haha");
        }
    }

I haven't found any information on needing to use a different socket type for mobile internet connections, so I'm wondering what I'm missing here.

Bjorn De Rijcke
  • 653
  • 10
  • 23

1 Answers1

0

I am using the following code that allows me to connect to the desired device via WiFi, but it isn't working via the mobile broadband connection.

It's not the problem with StreamSocket connection, so couldn't you find any information on needing to use a different socket type for mobile internet connections.

"10.203.120.71" is a LAN IP address, when your computers are connected to a WiFi router, this router is first connected to your company's network, in other words, your computers are all connected inside of your company's LAN.

But when you use the broadband of your phone, the network of your phone is outside of your company's LAN, so can't this phone connected via this "10.203.120.71" address.

The device contains a Machine-To-Machine SIM card that links to our company network.

So if your phones link to your company network through WiFi, it should also work fine by this code. Otherwise you will probably need a VPN server for this, the phone can link to this VPN server through other IP address, and the VPN server can be connected to "10.203.120.71" address.

If this is not the reason which cause your problem, please check the exception to clarify the root cause.

Grace Feng
  • 16,564
  • 2
  • 22
  • 45
  • Perhaps my wording was a bit wrong, the M2M SIM card works like a vpn tunnel into our company network giving the device an internal IP. But your answer gives me directions that it is not the application I need to debug but our network topography. Thank you! – Bjorn De Rijcke Mar 03 '16 at 09:29
  • @BjornDeRijcke, You are welcome, yes it should be the problem with network topography, maybe my answer is not quite right for your scenario, I can't find any useful information for now, but there is a similar case [Can't establish connection using StreamSocket (universal windows)](http://stackoverflow.com/questions/33895024/cant-establish-connection-using-streamsocket-universal-windows) with no answer but discussions, you can also take a look. Thanks for marking my answer. – Grace Feng Mar 03 '16 at 09:47