Author Topic: Hard coded multicastIP purpose  (Read 2299 times)

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Hard coded multicastIP purpose
« on: November 25, 2015, 12:53:17 AM »
I am curious, I found this line in the UdpProtocol class

// Cached broadcast end-point
static IPAddress multicastIP = IPAddress.Parse("224.168.100.17");

Which is used here

IPEndPoint endPoint = mMulticast ? mMulticastEndPoint : mBroadcastEndPoint;


And I cannot understand why that IPAddress is hard coded? And what is it used for?


The bigger issue I am dealing with is that when I am running Unity Editor in iOS mode on my mac computer
and Unity Editor on my Windows 7 computer
then When the PC is the Host the Mac Client can connect
But when the Mac is Host the PC cannot find the Host.

That was when I have set
static public bool useMulticasting = false;
Based on your previous posts mention that iOS cannot use multicast

If I change it to
static public bool useMulticasting = true;
And change the Mac to android then PC android and Mac android can both host and client.

I found some weirdness for windows broadcast, I am not sure if it is related

https://social.technet.microsoft.com/Forums/windows/en-US/72e7387a-9f2c-4bf4-a004-c89ddde1c8aa/how-to-fix-the-global-broadcast-address-255255255255-behavior-on-windows?forum=w7itpronetworking

So I guess my second question is, is there a way to get Unity Editor PC running Android and Unity Editor MAC running as iOS to talk to each other properly on a LAN?

phoenix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 49
    • View Profile
Re: Hard coded multicastIP purpose
« Reply #1 on: November 25, 2015, 02:09:57 AM »
I was able to get it working by commenting out the detection of  multicast for iphone
with    static public bool useMulticasting = true;

 //#if (UNITY_IPHONE && !UNITY_EDITOR) //|| UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
//         IPAddress networkInterface = useMulticasting ? multicastIP : (defaultNetworkInterface ?? IPAddress.Any);
         IPAddress networkInterface = defaultNetworkInterface ?? IPAddress.Any; //0.0.0.0  x ?? y – returns x if it is non-null; otherwise, returns y.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Hard coded multicastIP purpose
« Reply #2 on: November 25, 2015, 06:35:09 PM »
If you want to force using of multicasts or broadcasts, simply set TNet.UdpProtocol.useMulticasting = true or false at the beginning of your app. There is no need to alter code.

Multicast address is hard-coded so that all TNet apps can use the same one. Think of it as being able to join the same Google Hangout group. It's not an external address.