• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android multiplayer on Android

RizbIT

Member
I knwo how to use tcp to connect devices, but to date i always work with desktop windows apps.

When working with android multiplayer apps, do you still have to account for the issues relating to port forwarding??

so say i have two Android phones that are connected to internet via data connection. Can i run server app on one phone and connect to it via client app on other phone?

Will it work without having to fiddle with tihnggs like firewall or port forwarding on the phone?
 

Roderick

Member
I haven't done any significant networking in GMS, but when I was doing the tutorials in Heartbeast's book, I compiled two copies of his networking project: One on my computer and one on my phone. It worked fine, so I'd assume that in most cases, you shouldn't have to do anything special to make it work.
 

RizbIT

Member
to connect two phones in different countries you would need the external IP of the server app i guess. how do you get the external ip of the phone
 

Freddy Jones

Your Main Detective
Yes you still have to port-forward. If your phone is on wifi you'll have to open the ports on the router you plan to be used when hosting a game. This isn't necessarily possible on a mobile network, and even if you could find some sort of way to do it via an agreement with your plan, it would be completely unreasonable. What you would do is either have a master server that you host yourself or in the cloud which acts as the center ground and does all the handling, or you'll have to use UDP hole-punching which I'm not even certain would work even half-reliably on mobile networks.

Your best bet would be to host a server that handles the communication between phones if the hosting phone isn't guaranteed to be in an environment where its hosted port is usually open.

You can get your phone's global ip easily by just googling it. "What's my public IP" and you'll eventually find it if you look a little (if not already in your face).
 

The-any-Key

Member
Note that 3G/4G networks mostly block incoming connections (but it works on some providers). You can run a client on mobile networks if the host is on a non-mobile network. Well if you got a mobile network router at home it should work to start a connectible host on.

But you can use a small relay server at home to allow you to "host" on 3g/4g networks. It would work like an extension/handler/workaround/loophole of the mobile network. But every player that plan to host on 3g/4g would need to setup one at home.

A mediation server combined with UDP punch and upnp can mostly take care of the port forwarding and the connection.
 

Freddy Jones

Your Main Detective
@The-any-Key you're Knight, aren't you? Didn't think I'd bump into on the GMC haha.

Points about UDP hole-punching and mobile networking is that it's very unreliable, far more so than on a normal connection. If your game doesn't have any fallbacks like a passthrough server then you're going to have users complaining about a broke game. Also, if you're using UDP you're mostly making some packet-heavy and twitch based games which would consume quite a bit of data on the mobile user's phone, and it will really consume a lot of data for the serving phone.

My two cents
 

salyossy

Member
I knwo how to use tcp to connect devices, but to date i always work with desktop windows apps.

When working with android multiplayer apps, do you still have to account for the issues relating to port forwarding??

so say i have two Android phones that are connected to internet via data connection. Can i run server app on one phone and connect to it via client app on other phone?

Will it work without having to fiddle with tihnggs like firewall or port forwarding on the phone?
I know its old... but, have you found some answers you could share? how did you establish a server for connecting two or more android phones? thanks :)
 

RizbIT

Member
not really what i did was create server on desktop version and client on app.

another solution buy a always up windows based server you can then install and have the server app running on there and all client apps on mobile connect to it
 
Top