Closed trampster closed 4 years ago
Would it be correct to assume that you do not have multicast in this situation?
Yes
Please check to see of pull request #82 solves your problem.
That solves our problem, not sure of the threading here, maybe UseReceiveMessageFrom should be volatile, given that it is changing in one direction only (true to false) its probably OK, if a thread gets a cached version of it then it would just get the exception and then set to false and then be OK from then on.
It would be a nice if there was a way to detect we are running on mono and avoid the exceptions all together but I can't see any .net standard API that would do this.
The threading is not an issue here because it is serialized farther up the stack.
It is possible to check if it is running on mono, but I don't know if it would be a valid check. It may be that mono does support this API for other platforms than Android. I would expect that it might be in iOS as multicast is easier to have running on that platform.
It's missing in the mono socket implementation see https://github.com/mono/mono/issues/20197, I wouldn't expect it to work on any mono platform.
Here is the socket code https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.Sockets/Socket.cs
This is the accepted way of checking for mono: https://github.com/dotnet/runtime/blob/a297222753da9ae62dfe3304e4924ff74693c77d/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs#L22
At least your way would start using the new API if mono ever did implement it.
I have no problems with making it mono dependent, but for now I think I will leave it along. One of the things I would really like to do is to run the unit tests under mono using the netframework but I have never been able to figure out a good way to do this. Do you have any setups for doing so?
I also assume from this that the decision I was thinking about of dropping the net framework version from the distribution would not make you happy,
We use it from .net standard, so if you only target .net standard then that would be fine with us. We use the .net standard version from mono on Android and iOS.
However .net standard isn't evenly implemented, mono 'officially' supports some .net standard api's by throwing either NotImplementedException or PlatformNotSupportedException, and the only easy way to find out is by using your .net standard libraries on mono :(
4 months ago ReceiveFromAsync was changed to ReceiveMessageFromAsync, but on Xamarin.Android this throws a NotImplementedException.
Here is the commit that changed it: https://github.com/Com-AugustCellars/CoAP-CSharp/commit/451e5bba4d2941a457b0741cc70631d0722a4f0c