Android multiplayer on Android

Discussion in 'Game Design, Development And Publishing' started by RizbIT, Jan 31, 2017.

  1. RizbIT

    RizbIT Member

    Joined:
    Jun 24, 2016
    Posts:
    440
    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?
     
  2. Roderick

    Roderick Member

    Joined:
    Jun 22, 2016
    Posts:
    577
    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 likes this.
  3. RizbIT

    RizbIT Member

    Joined:
    Jun 24, 2016
    Posts:
    440
    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
     
  4. Freddy Jones

    Freddy Jones Member

    Joined:
    Jul 3, 2016
    Posts:
    167
    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).
     
  5. The-any-Key

    The-any-Key Member

    Joined:
    Feb 2, 2017
    Posts:
    1,521
    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 likes this.
  6. Freddy Jones

    Freddy Jones Member

    Joined:
    Jul 3, 2016
    Posts:
    167
    @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
     
    The-any-Key likes this.
  7. The-any-Key

    The-any-Key Member

    Joined:
    Feb 2, 2017
    Posts:
    1,521
    Joined today o_O
    (Makes the bump even more incredible)
     
    Last edited: Feb 2, 2017
  8. salyossy

    salyossy Member

    Joined:
    Aug 10, 2019
    Posts:
    10
    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 :)
     
  9. RizbIT

    RizbIT Member

    Joined:
    Jun 24, 2016
    Posts:
    440
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice