hari
hari

Reputation: 2769

Port Forwarding using Sockets

I created a ServerSocket made it to listen to a particular port.If i use an app which runs on my mobile i shld use my public IP and make my router forwd to my local IP. Wht port no. in router shld i forward ?

Upvotes: 0

Views: 858

Answers (1)

Marvin Pinto
Marvin Pinto

Reputation: 31038

You haven't provided a lot of details to go on so I'll make a few assumptions:

  • Your Android app is listening on port 9923.
  • From the way you phrased your question, I'm going to assume you're connecting via WiFi.
  • The other party is (somehow) already aware of your app's public IP address.
  • The other party will initiate all communications through port 9923.

In this scenario, you will forward port 9923 from your router to your Android's IP address. Put another way, any incoming packets destined for port 9923 on your public IP address will get forwarded to port 9923 on your Android's IP address.

Now if you're attempting to do with over 3G, be aware that not all carriers allow you to listen on certain ports or keep sockets open, so this is something to keep in mind.

Upvotes: 1

Related Questions