WiFi Networking when app is developed Godot - C# - VSCode - Xcode

I'm developing a 'game' using the Godot game framework. The 'game' will run on an IOS device and connect to an app that is running on my computer. The app I am connecting to communicates via UDP.

When I run the app in Godot's simulator using either the loopback address 127.0.0.1 or the WiFi address of the computer it works fine.

I am attempting to send a Unicast UDPpacket from the IOS device to the computer. The UDPpacket is never sent from the IOS device as verified by Wireshark and also the network tab on xcode as the 'game' is debugged via Xcode.

The first time the app is sent to the iphone during the debug session from Xcode, a message on the iPhone pops up "MyAppName" would like to find and connect to devices on your local network. (I clicked on "Allow")

When the app is debugged on the iphone via Xcode,

  • debug message from near the point where UDPPackets are sent are displayed in the debugger.
  • After about 5 seconds an error is thrown from the UDPClient "No route from host..."
  • There is a loop to send UDPpackets is again if the expected response is not received from the app,
  • the "No route from host" again is shown in 5 seconds.

Settings:

  • Ip address on computer and iphone are within the same network (do not need to be routed)
  • Firewall is off on the computer during testing
  • iPhone Settings (MyAppName is not shown anywhere in settings)
  • Godot 4.2.1, .Net 8.0.101, XCode 15.2, VSCode 1.85.2

**Godot editor -> Project -> Exports -> Presets -> IOS (Runnable) **

[Options Tab]

  • Access WiFi [x] is checked
  • Provisioning Profile UUID for both Debug and Release is BLANK

[Resources Tab]

  • {All fields are blank}

[Features Tab]

  • Feature list = arm64, astc, etc2, ios, mobile

[Encryption Tab]

  • {everything is off or blank}

I suspect that I'm not using entitlements properly. I have been granted the multicast entitlement, but I'm not certain how to implement it in my Godot -> VSCode ->Xcode workflow.

I suspect that I'm not using entitlements properly.

An iOS app doesn’t need extra entitlements to use the local network. The multicast entitlement is only necessary if you send or receive multicasts or broadcasts. I talk more about this in the Local Network Privacy FAQ.

Problems like this are almost always caused by folks using BSD Sockets… well… not so much incorrectly but… well… Sockets is a wacky API and there’s a lot of variation between platforms and it’s easy for code written for one platform to fail another.

I provide some background to this in TN3151 Choosing the right networking API and more in the posts linked to by Extra-ordinary Networking here on DevForums.

To help you with a question like this I need to know what APIs your framework is calling and how it’s calling. Specifically:

  • Are you binding the socket to a specific address?

  • Are you connecting your socket?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Here is the start method for the app: Does UDPClient use BSD sockets 'under the hood'?

    public void Start()
    {
        try
        {
            OnLog = new LogHandler(LogHandlerMethod);
            _client = new UdpClient();

            _client.Client.Bind(new IPEndPoint(IPAddress.Any, 0));
            OnLog?.Invoke(String.Format("Client Local  Endpoint is {0},", _client.Client.LocalEndPoint.ToString()));
            _ts = new CancellationTokenSource();
            var token = _ts.Token;

            _serverTask = Task.Factory.StartNew(async () =>
            {
                try
                {
                    while (!token.IsCancellationRequested)
                    {
                        var response = await _client.ReceiveAsync().ConfigureAwait(false);
                        // Check if the received data is from the specific endpoint

                        var raw = Encoding.UTF8.GetString(response.Buffer);
                        LastReceive = DateTime.Now;
                        LastBuffer = response.Buffer;

                        OnRawReceive?.Invoke(raw);
                        ParseResponse(response.Buffer);
                    }


                    OnLog?.Invoke("Stopping server");
                    _client.Close();
                }
                catch (Exception ex)
                {
                    OnLog?.Invoke($"Exception in serverTask: {ex.Message}");
                    throw;
                }
            }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default);

            _observerTask = Task.Factory.StartNew(async () =>
            {
                try
                {
                    while (!token.IsCancellationRequested)
                    {
                        foreach (var dr in _DataRefs)
                            if (dr.Age > _MaxDataRefAge)
                                RequestDataRef(dr);

                        await Task.Delay(CHECKINTERVAL_MILLISECONDS).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    OnLog?.Invoke(ex.ToString());
                    throw;
                }

            }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
        }
        catch (Exception ex)
        {
            OnLog?.Invoke(String.Format("Error in Start method {0]", ex.ToString()));
            throw;
        }
    }
WiFi Networking when app is developed Godot - C# - VSCode - Xcode
 
 
Q