Windows 10 UWP app: StreamSocket via mobile broadband - c#

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.

Related

communicate on public ip from socket

apologies for weak English
Hello my friends
I have a problem that very confused me
Project description:
I created c# wpf project for server side and android studio app for client side. in wpf I coded socket communication codes also in android studio. main point is I connected my phone to pc by charger cable as modem to connect the internet. also use the phone for debugging android studio app. when I test the communication between my pc and phone established successfully . it connects very good on android virtual device manager too . but when my friend install client app on his phone , connection is not established and my ip (192.168.xxx.xxx) is not accessible for client. I tried by my public ip founded from whatismyip.com but I don't socceeded
thanks in advance
special thanks for you and other friends
For safety reasons your modem is blocking request that come from the outside of your local network. You must setup a NAT/PAT on your modem to allow external request to be treated. There is tutorial on internet depending on your modem.
Hope that will help you.
Have nice day !
your private IP "192.168.xxx.xxx" is not routed over internet, you have to use your public IP provided by your ISP provider(NAT), if you are using ADSL router, log in to it IN ORDER TO find your public IP, then do port forwarding to your local IP address,and enable dynamic DNS, then you can access your private IP using public IP from anywhere over internet

Android UDP broadcasting works but direct IP not working

I've published an Android app which communicates with a C# server app via UDP. I've implemented an "Auto Connect" feature which does broadcasting and receives an answer from the server. Once an answer received by phone, the phone app holds the sender IP and sends subsequent messages to this IP directly. Also there is a Manual Connect feature which sends data to the IP address the user enters (which is the local IP of the PC running the server app).
So, everything works great for lots of users but some users reported me that when they use manual connect, it never connects; when they use auto connect, the server gets the broadcast message (seems connected) and the phone receives the answer but afterwards none of the (direct) messages will be received by the server app. The common point of these users is that their PCs are connected to the WiFi router by wire and their phones are connected by wireless. I've tried the same thing on my network but again it works for me without any problem.
May it be because of having multiple network interfaces (both LAN and WLAN)? I've been searching net for 1 week but no success.
What should I do? Please help.
Thanks in advance.

Can we establish a connection-less or connection-oriented nature of a connection between 2 computers connected via bluetooth?

This sounds a silly question, but I'm trying to create a network between 3 computers over bluetooth, can we try to establish a connection-less or connection-oriented connection between each node, just like we do in IP networks.
Its possible to do peer to peer networking with bluetooth, the how depends on your OS,
here are a few examples,
Linux
http://giovanni.wordpress.com/2007/04/06/how-to-use-tcpip-over-bluetooth/
Windows
http://www.conniq.com/Windows-networking/Bluetooth_PAN_xp-setup_12.htm
Android
https://android.stackexchange.com/questions/6072/is-it-possible-to-have-a-tcp-ip-network-using-bluetooth
Note:
this will depend on the profiles your BT device/stack supports,
http://en.wikipedia.org/wiki/Bluetooth_profile
the LAN access profile lets a bluetooth device access the internet via a bluetooth enabled router or access point.
The PAN (personal area network) profile will allow you to do what you are describing. It essentially looks like Ethernet, so you can do anything with it. of course for what your describing you will need static ip addresses, but then you should be able to ping, make sockets, whatever.
Again the device and the OS has to support this profile, but most should.

WP7: TCP connection from phone to PC via USB

I'm trying to get a connection via TCP sockets from my Phone that is plugged via USB to the PC. It does not seem to work. The Socket.ConnectAsync returns a Success, so the hostname (name of my PC) is correctly resolved. However, the first Socket.SendAsync ends up in a Connection Reset.
It works with the emulator and if the PC and phone are in the same private WiFi network, but never via the USB connection.
This is kind of strange, since HTTP traffic seems to work quite well: The phone's browser can connect to my PC's webserver (with both PC and phone beeing offline, just connected via USB) and a small test app can connect via HTTP (WebClient) to the PC, like asked in this SO question here.
So my question is, as there must be some security restriction that I did not discover yet, or some technical restriction: How can I get it to work, and if not, why?
Thanks in advance for any help with this!
Have you tried doing a connection using the Socket class to the web server (ie. port 80) on your computer?
I'm pretty sure the USB Connection Sharing for WP7 is restricted on the ports that it actually shares. I could be wrong, of course, but this would explain your situation.

how to do point to point communication in windows phone 7 over gprs

can somebody help in finding out any way about how we can do point to point communication with windows phone 7 and a desktop computer over gprs.
Please it has becoma a showstopper for our project..
Thanks
Edit 1:
Yahya, The computer is having internet and also gsm modem with a network provider sim and the mobile is also having a sim. Where ever they are they have internet and we want to see each other or can send msg to each other over gsm, because when a gsm modem having proper data enabled sim from a mobile network operator is attached to a computer then the computer should able to talk to the mobile over gprs, because the mobile is also holding a valid gprs enabled sim.
Provided that both your endpoints Windows Phone 7 and Desktop have a SIM (or modem with a SIM) inside, you surely know the phone numbers of those SIMs.
if you want to communicate via GSM or via SMS you can send a SMS (Short Message) from one to the other and parse received messages on both and check if the message comes from the other side by checking the sender number than parse the data in the message as needed.
Differently if you go over GPRS or Data Transfer and you are on the Internet then the desktop could host a web service in IIS for example so the Phone can directly connect to such web service and call a method passing the data required to be transferred.
in fact you only need the phone to know the IP address of your server or desktop and to connect and consume the web service via the Internet when data connection is available and if not you can send a SMS to the desktop' SIM card.

Categories