简体   繁体   中英

Windows 10 UWP app: StreamSocket via mobile broadband

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM