13251

Use Socket-communication over different networks

Question:

Hello fellow stackoverflowers!

I'm currently developing this app that should be able to communicate device-to-device. I found <a href="http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/" rel="nofollow">this</a> 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.

Answer1:

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.

Recommend

  • Filtering in Pandas dataframe slow for “large” number of groups?
  • How can I access injected Grails beans in an abstract class method?
  • JDBC Connection Configuration for MYSQL not working in Jmeter
  • how to enable Wi-Fi and search for networks on windows phone emulator
  • wix: re-start an existing Service when install/uninstall finish
  • My phone is not moving, but GPS data still changing
  • URL hash format, what's allowed and what's not?
  • Can someone explain the behavior of the functions mkpp and ppval?
  • Git cherry pick those commits that contain a keyword (tracking id)
  • Global CSS for an app with web components
  • In built Elastic Search analyzer which does work of Simple Analyzer as well tokenize the number
  • Rally Kanban - hiding Epic Stories
  • Reactor way to cancel Subscriptions
  • Delete multiple lines - from “patternA” match, through second occurrence of “patternB”
  • Whats the best approach to use q promise in a loop? Waiting for chain to complete before iterating t
  • Apple Reachability Notifications for Network OR Wi-Fi
  • Catching the url path following a python cgi script?
  • C#, “Object reference not set to an instance of an object.” error
  • Enable Bootstrap Intellisense using Angular 4 in WebStorm
  • Receiver has no segue with identifier“***”
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • aapt.exe'' finished with non-zero exit value 1
  • C# fibonacci function returning errors
  • Android app gives error “BatteryStatsImpl: reading network stats”
  • Spring Cloud Microservice Architecture Confusion
  • Transactional Create with Validation in ServiceStack Redis Client
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Avoid links criss cross / overlap in d3.js using force layout
  • Handling un-mapped Rest path
  • Recording logins for password protected directories
  • SignalR .NET Client Invoke throws an exception
  • PHP - How to update data to MySQL when click a radio button
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET