Is there any way to actually communicate between two android devices over internet without having to have any service between the two devices?
Like posting something to device2 from device1 without having to "middle-land" on any other server or whatever?
Another question: I tried to ping my phone over the internet (simply using the IP address), which didn't work, since it seems like my ISP shares the same WAN-IP for all the phones or at least a few of them. So is there any way to actually ping or send data to my specific phone just by using the IP or my Google account or something?
Almost all the end user devices are behind a ISP's router, and many of them behind a lot devices in network hierarchy; Thus it is exceptionally rare that an end user device has public IP address.
Even if you want to run a public request listening server, you don't have to get public IP address for your device, rather a redirect is created at the router, which redirects certain requests to your device.
Having that said, you cannot communicate between two end devices using internet without a public server in-between them.
So your possible solution could be: (If you don't want to use an in-between server), you can send data using mms directly to mobile number.
BitTorrent is P2P and works from behind common WAN IPs as well. You can implement something similar, but you will need to know the IP addresses of Devices A and B and the ports on which communication is to occur. These ISPs usually allow dynamic port forwarding.
You should attach static ip to one of devices. If you connect to Internet from your mobile service provider, providers usually dont supply static ip. You can get your ip dynamically and send to other device via sms.
Related
I followed a chat app tutorial that connects devices using TCP sockets.
For simplicity, I split the app into 2, so that one is the server and the other is the client.
The app works fine when I am using the same wifi network, but it does not when one of my devices jumps into a different network.
This is where I get confused on the concepts.
Because they are different networks, I cannot use the local IP as I have been doing. I did find using the public IP is possible, but I'm still new to coding so am not sure if that's the right method. Should I look into VPS? Or GCM?
Do I need to rewrite my app such that I have 2 clients (that talk to each other) and that they go through the server with a static IP (like a middle man)? But then I get confused because in that case, Client would start first and then talk to Server. But I always thought Server was to start first and wait for an accepting socket??
Not sure if this is the right place to ask these questions, I'm just really confused on the concepts. Thanks!
For socket programming in your apps, the only info you need is IP address and port number. After switching to another network, the only modification to your source code is IP address.
When devices are not in the same local area network, you need routers to locate each other, in theory. If you don't own control to routers, using a public and static IP is the right solution. The app acting as a server should have this static IP and should always be alive, and listen to connections. The app acting as a client starts later and connects to the server with its IP address and the port number you've defined.
Normally when you get access to Internet, you get a public IP from your ISP, and it keeps static if you keep online, in most cases. So just find out the IP address on your server, and connect to this IP address from your client app. If your internet access is gained from a wireless router, you should set up port forwarding on the router, and use the IP address of this router at client.
I'm aware it's been asked before (with limited or no solution) but I haven't seen any recent updates and I think my scenario is unique so I'll start a new thread.
I have a Raspberry Pi and it's functioning as a hot spot among other things. By design, DHCP isn't handing out a default gateway. My use case is one or more devices interacting with the Pi as a server.
One of the connected devices will be a mobile device(edit: running a custom app of my design which is part of the total solution), and that device will maintain its cellular connection, not for tethering or routing but so that the application can access internal and external resources simultaneously.
Currently:
IOS: This works exactly as I expect on IOS - it senses that the WiFi network doesn't have a default gateway and sends external traffic over cell.
Android: This doesn't work at all. Android stubbornly sees WiFi connected and disables cellular, even with no default gateway.
Windows Phone: Kind of a hybrid. Both networks stay up but my scenario has a DNS entry in public DNS, and a public site links to a resource on the Pi. If I link to the resource directly using the WiFi IP address of the Pi, it works fine (although this causes other issues related to security). If I link via a FQDN, I'm actually not sure what's going on. It doesn't resolve from the web browser although every networking utility I've installed on the phone for troubleshooting correctly resolves the FQDN to the Pi address via DNS.
Hope this makes sense. The question: How can I enable this functionality across the board in 2015? :) For my purposes, the Pi as a private nonroutable hotspot works better than WiFi direct or Bluetooth. And remember I'm not asking the phone to ROUTE; I need my custom application to be able to simultaneously connect to the Pi and to the public Internet. I want all the phones to do what IOS does in this regard.
My current scenario is the Pi hosting a web page (among other things) and that's my preference, but can this even be solved natively?
You say that this is not a tethering or routing situation, but if you think about it, it really is both.
It is routing because the traffic from the phone needs to be routed to one of the two interfaces. There may not be routing through the phone, but it's still a routing problem. Fortunately, it seems that the routing part is working on all three platforms.
It is also an unusual form of tethering. The only differences are that traffic does not originate from the Pi, but from the phone, and that the Pi rather than the phone acts as the access point.
Thinking of it in terms of tethering is important because it shows that the Android CAN have WiFi and cellular active at the same time (at least in hotspot mode, but probably also in client mode). In this respect, my answer isn't complete - I can't tell you HOW to accomplish that.
As for the Windows phone problem you mentioned: in order to troubleshoot that, first identify where the DNS server is located that knows about the Pi's FQDN. Does a public DNS server know about it, even though it is obviously on a private network?
There are two possible explanations for your observation:
There is no public DNS server that even knows this FQDN. In that case, IOS is probably using something like mDNS to locate the Raspberry Pi.
There is a public DNS server that knows this FQDN. In that case, maybe Windows Phone checks the DNS reply for martians and rejects it, thinking that it is an attack.
Either way, what you'd really need is to have two separate DNS infrastructures. One way to do this is to include a small DNS server (dnsmasq maybe) with your app, and configure a forwarder for the zone with the Pi's FQDN to forward to the Pi's IP address (which would have to be hardcoded, obviously). All other requests should go to the normal DNS servers.
Another way might be to not use DNS at all, but use the hosts file instead.
For Android phone you can use application named "WiFi & Mobile Data Switch" (https://play.google.com/store/apps/details?id=com.totemsoft.wifimd). For me it solves the problem of simultaneous connecting to internet (via mobile data) and to local network (via WiFi, internet is inaccessible via WiFi). This applications works ok on Samsung Galaxy A8. I hope, my comment helps to somebody.
I have an app that runs in an emulator. The app sends multiple messages to my local server, for manipulating data. While i was using the app in my emulator i was using:
http://10.0.2.2/path
to reach the server. I would like to use a physical device to connect to the server. Does somebody know how to do this. What adress i should use?
Assuming that your devices are on the same Network (connected to the same router) as your computer, you can expose your computer's web server (Apache, presumably?) and then point your app directly at the local network IP address that your computer has (usually something like 192.168.1.x). I have found that the least painless way to do this is to use MAMP or WAMP or LAMP depending on your OS, but of course I have no idea what your specific situation is, so that solution may in fact make things a lot more complicated rather than less.
In any event... your computer is on the network at a specific IP address, so it's just a matter of making sure that it's willing to serve this data on whatever port you are looking for it on. If you provide more specification as to your circumstances, we can give a more detailed answer.
I am wondering how can I make real time data exchanges on mobile phones like whatapps, viber or skype do on phones. Until now I managed to make a server work on my android phone with web services but it works only with a wifi network as when we use 3G or edge connections, we have private IP Addresses and I can't be joined when using 3G. Of course I can buy a public IP address but I didn't have to when I use viber or whatapps, so I guess there is a solution.
So my question is how to get around those NAT (Network Address Translation) without having to make a periodic check for data?
A bit vague question. But these apps all basically do either tunneling via external server or NAT traversal. And there are lots of different techniques available...
Since phones can change their IP interface (and address) every few seconds, defeating NAT may not be such a good idea.
I have multiple T-Mobile Android cell phones and I am writing an app to go on all the phones that exchanges data via IP. Is there a way to get the private IP addresses of the cellular connections, and send data to each phone using those addresses?
You might wish to create some kind of intermediary web service that all of the devices talk to to share their IPs. Some kind of simple, RESTful API that I device could call to POST their IP/MEID and fetch the other devices' IPs.
You can use something like this to get your device IP.