Andrea Pasin
Andrea Pasin

Reputation: 43

Socket connection over Mobile data

I'm developing an Android application that is required to send data over the Internet without using WiFi.

Is it possible to connect a socket to a server via Mobile Data?

My application works with WiFi, but doesn't work with Mobile Data.

Upvotes: 1

Views: 2563

Answers (1)

Luke
Luke

Reputation: 1344

You haven't really said what's the problem, so here's a wild guess:

You're developing on a local server, on address 192.168.something.something. On your home WiFi everything works, on mobile data it can't find the server.

If so, 192.168.*.* are local addresses. They are bound to your router and requesting them never reaches the internet because they are handled locally, which is totally fine if you're connected to that router. On mobile data, however, you aren't using the router which would resolve a local address, but rather a mobile tower which has no idea what you're asking it for - it doesn't know 192.168.*.* is your computer, so you can't establish a connection.

For the most part, transmitting data over WiFi and mobile data should make no difference. If there is, the problem is probably somewhere else. So here, in order to make it work with mobile data you need an actual remote server (which could be hosted on your computer if your ISP allows that, but that's another topic).

You do need to provide a better explanation for your problem - what address you are accessing and what's the error? I only have this hunch (and I'm quite confident in it) because I have at least one more answer with identical solution somewhere on the site (and the question was quite similar), which means you probably could've found it using Google (edit: yup, here it is).

Upvotes: 2

Related Questions