I’ve found that since the deprecation of Mono with Unity, I’ve been experiencing application crashes/halting (without any exceptions being thrown) when trying to add a membership to a socket.
A simple script on an object in the scene replicate this behavior:
private void Awake()
{
Debug.Log("Creating Socket...");
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPAddress IPAddress = IPAddress.Parse("239.255.255.250");
Debug.Log("Setting Socket Option...");
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress, 0));
Debug.Log("Successfully Set Socket Option...");
socket.Close();
Debug.Log("Closed Socket...");
}
In the editor, it successfully prints all the logs, but when running on the device, it halts execution and never prints “Successfully Set Socket Option…”
Notes:
- Unity 2019.2.12f1
- Reproducible for Windows Standalone w Il2cpp & PS4 (and possibly others, but not in editor)
- Tested with and without Development Build checked. Same results.
- Tested with 4.x and Standard 2.0, same results. (Baselining 4.x)