Search code examples
c#iosunity-game-enginenetwork-programmingtcp

Is System.Net.Sockets compatible with Unity targeting iOS?


I have created a Unity application that uses System.Net.Sockets for TCP communication with a separate server computer. This application works flawlessly in the editor, and when built for Android or PC. But when I tried to create an iOS build (on a MacBook) the app loads correctly, but no network communication is made.

Next I created a developer build, but no errors or warnings appeared during runtime, it just didn't connect to the server. I made sure to double check that they were both on the same network, and that the ports are set correctly.

I am currently debugging and looking through documentation, but I haven't seen anything stating that System.Net.Sockets is incompatible with iOS. Once the following questions are answered I can upload code snippets / ask a new question about the specific code.

Does Unity support System.Net.Sockets for iOS? Is there something unique that needs to be done when building a networked project for iOS?

Thank you for your time and assistance!


Solution

  • A quick pathetic answer:

    • Whether or not System.Net.Sockets in Unity works in iOS / Android builds is one of the great mysteries of the ages, and the answer changes every few months :/

    • I am almost certain it is currently possible ...

    For example, notice this popular library https://assetstore.unity.com/packages/tools/network/best-http-2-155981 which works perfectly with ios/droid, and indeed is ultimately just .Net underneath.

    (A worthwhile tip is, get on the forum of that library and pose your problem...)

    Problems ...