0

I am new to android development and socket programming.I am trying to connect two mobiles on different networks using sockets. I was able to connect two devices on same network or LAN. I would like to ask two things. 1. How can two devices can communicated lets say one on 3G and other using WIFI. 2. What is this string fe90::c762:7acc:a801:dc87%wlan. The following link has the code which retruns two things one the above string and another 192.168.1.5 like an ip adress. I am not sure what that string is. Can someone please explain? thanks!!

Code that returns that string

Community
  • 1
  • 1

1 Answers1

0

I am trying to connect two mobiles on different networks using sockets

Generally, that will not be possible.

How can two devices can communicated lets say one on 3G and other using WIFI

Generally, that will not be possible. Most WiFi networks issue private IP addresses; most mobile carriers issue private IP addresses. You would need one or both of them to be public IP addresses to directly communicate with each other. This is a standard P2P communications problem and has nothing specifically to do with Android -- you will run into the same problem connecting two desktops on different networks.

What is this string fe90::c762:7acc:a801:dc87%wlan

That is an IPv6 address with a zone index.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Hmm.. Thats exactly what I want. P2P communication. Like you said most of Wifi networks and mobile carriers issues private IP then how P2P is possible? – user3787605 Oct 09 '14 at 16:40
  • @user3787605: Literal P2P may not be possible between two devices on separate mobile networks. I would assume that you will need some intermediate server that can be reached by both sides. I suggest searching `android p2p library` on your favorite search engine. – CommonsWare Oct 09 '14 at 16:44
  • Design of my app is, I'll have a server and each device will be connected to the server whenever it'll be connected to internet. And if device A wants to communicate device B then A will gets B's ip address from the server and then connection establish phase and then p2p communication starts. But you are saying it isn't possible.Right? – user3787605 Oct 09 '14 at 16:57
  • @user3787605: "But you are saying it isn't possible.Right?" -- correct. – CommonsWare Oct 09 '14 at 16:58
  • lol sorry that am asking stupid question. One last question. I am developing an IM for android and I want p2p communication. What will you suggest? How is this possible? Any library or anything? – user3787605 Oct 09 '14 at 17:03
  • @user3787605: Many IM solutions use XMPP servers, and there are XMPP libraries for Android, such as aSmack. – CommonsWare Oct 09 '14 at 17:04