Zeeshan Chaudhry
Zeeshan Chaudhry

Reputation: 862

Android P2P connection on WAN

I successfully connected connecting 2 android Mobiles p2p using:

        //On server 
        public static String SERVERIP = "192.68.100.104";
        public static final int SERVERPORT = 8080;
        .
        .
        .
        //on Client
        Socket socket = new Socket(serverIP,SERVERPORT);

Now I need to connect Devices on WAN, So that the server can access by any Client who knows Server WAN address.
I get my IP by this link now how can I use this IP so that my server can be accessed from any part of world. Thanks

Upvotes: 2

Views: 1188

Answers (2)

GETah
GETah

Reputation: 21409

You are probably setting behind a router which hides your local IP address from the rest of the world (look for NAT for more info on this). Basically, the world only sees your YOUR_ROUTER_IP (the one you get from the link you posted), your router takes care of carrying all IP packets from the outside world to you and vice versa. You will need to change your router settings so that your local device gets the router ip address. This way you can access your server application from anywhere in the world by using simple socket operations. I hope this helps.

Upvotes: 0

Yusuf X
Yusuf X

Reputation: 14633

If your server is on a WAN, it (probably) doesn't have a public IP address, so devices on the WAN can access it, but devices anywhere else in the world can't.

The easiest way to solve this is to install the server somewhere (such as AWS or any hosting service), then the clients can access that address.

Upvotes: 1

Related Questions