3

Hello fellow stackoverflowers!

I'm currently developing this app that should be able to communicate device-to-device. I found this cool guide on how to use Socket for that kind of communication. And it worked! ..ish.

My problem is that it only works while the two devices is connected to the same Wi-Fi. Which sucks... So if device-A is the server & device-B is the client, and I use the internal-IP address (like, 192.168.1.blahblahbla), it works.

-That's awesome, then why're complaining bro?

Well, I want to be able to connect to device-A's external-IP, the real IP (like 94.254.blabla.blabla). So my question to you guys, is how do I do that? How can I do something that can make this happen?

All help will be appriciated, thanks in advance.

Sincerly, Måns.

GuiceU
  • 1,030
  • 6
  • 19
  • 35

1 Answers1

0

This is morelike a networking question, but the answer is that there's no difference. The only different thing you have to bare with is with a firewall protection. If you can connect to a device using private IPs and not public, this means there's something blocking your connection (probably a firewall or the router's firewall).

You have to make sure the port you're connecting on the destination device is not blocked for your connection. The rest is the same.

nKn
  • 13,691
  • 9
  • 45
  • 62
  • Pretty much any *mobile* network provider is going to be running a firewall which blocks incoming connections. – Chris Stratton Mar 06 '14 at 21:16
  • I meant if the user is using a WiFi connection related to a router. – nKn Mar 06 '14 at 21:18
  • 2
    Ah, I should have read more carefully, I thought the poster wanted to support 3g, rather than disparate wifi networks. In any event, the general solution to both is an intermediate server on the public internet, as getting all those wifi networks reconfigured is iffy. – Chris Stratton Mar 06 '14 at 21:22
  • Agreed. I suppose the OP just wants to test around to see how these things go, but if this is intended to be a wide app, it definitely should be done in the way you described. – nKn Mar 06 '14 at 21:29