Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Send data via internet between two unity android app

Discussion in 'General Discussion' started by reiconrooc, Oct 29, 2020.

  1. reiconrooc

    reiconrooc

    Joined:
    Aug 11, 2018
    Posts:
    16
    Hi. Is there a way to send data via internet between two unity android app?
    The two apps will be in different devices and not in the same net.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Since devices on the Internet are typically on a NAT, you need a server of some kind to either set up the initial communication or relay all the data. That can be a server you rent or otherwise set up yourself, or a 3rd party service. For someone to give more specific recommendations, you'll have to be more specific with your requirements.
     
    Ryiah likes this.
  3. reiconrooc

    reiconrooc

    Joined:
    Aug 11, 2018
    Posts:
    16
    Is it possible to use the mac addres to identify devices to send data?
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    Only between machines on the same local area network (LAN). Once you start needing to work with different networks you need to start using an approach like the one described by @Joe-Censored.
     
    Joe-Censored likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    A MAC address has no layer 3 routing information, so can't be used to direct a packet through multiple routers towards its destination. An IP address on the other hand has all the routing information baked into the address, when combined with each router's own routing table.
     
    Ryiah likes this.
  6. reiconrooc

    reiconrooc

    Joined:
    Aug 11, 2018
    Posts:
    16
    Ok thanks. Does Unity provide a service for hosting servers?
    Or else, is it possible to use a device to be the server, and providing its IP (public) to others devices, have that other devices send data to it?
     
    Last edited: Oct 31, 2020
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,134
    No.

    Yes, but all of the limitations that come with trying to connect two devices directly together come with trying to use one device as a server. If the device behaving as a server is behind a NAT then you will need to have a relay server to access it from the client devices.

    I understand the desire to avoid having to deal with servers as much as possible but a relay server is both the easiest solution to this problem and very inexpensive. Amazon's EC2, for example, is only $3/mo ($2/mo for 2 virtual cores w/ 512MB RAM, $1/mo for 10GB storage) with no charge for the bandwidth used.

    https://calculator.aws/#/createCalculator?nc2=h_ql_pr_calc_smc
     
    Last edited: Oct 31, 2020
    MadeFromPolygons likes this.
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Not yet, but it supposedly is in the works. My expectation is the pricing will not be all that favorable. Taking 2 years to create what is essentially a management system for Google's existing cloud offerings also has me suspicious that Unity isn't really taking this seriously either.

    https://forum.unity.com/threads/game-server-hosting-feedback-and-questions.555076/

    Most internet connected devices are behind a NAT today, so the IP address the device actually has is not publicly addressable. This is usually worked around either by the already mentioned relay server solution, or a technique called NAT punch through. There are also cloud networking providers which implement this kind of thing for you.